Papua New Guinea is in political deadlock after its supreme court ruled that parliament had acted illegally by electing Peter O'Neill prime minister.
The government voted in August that the post was vacant after Prime Minister Sir Michael Somare went abroad for medical treatment.
The court ruled this was not the case, and that Sir Michael, who has since returned, should be sworn in again.
Mr O'Neill has refused to stand down, sparking fears of unrest.
Nearby Australia has said it is "deeply concerned" by the rising tensions.
Sir Michael left Papua New Guinea in March to receive treatment for a heart condition. In June, his family announced he was standing down from politics, a move he later said had been taken without consulting him.
He remained out of the country for five months and in August, MPs declared the position vacant and that Sir Michael was no longer an MP. Mr O'Neill was elected by 70 votes to 24, replacing acting Prime Minister Sam Abal.
But in a 3-2 decision on Monday, the supreme court ruled: "Sir Michael Somare is to be restored to the office of prime minister forthwith."
Sir Michael, who has been a major figure in politics for 50 years, said the judiciary had "once again upheld our constitution".
"My government followed process and waited for the appropriate authority, the judiciary, to make its judgement," he said.
He is expected to be sworn in on Tuesday, but Mr O'Neill said he would not cede power.
Reuters reported that heavily armed police prevented Mr O'Neill from reaching parliament to be sworn in late on Monday.
There were reports of scuffles outside Government House.
Papua New Guinea has seen extensive political violence in the past and there are concerns of a fresh outbreak.
"We are waiting for one of them to be sworn in," one resident told Reuters.
Australian Foreign Minister Kevin Rudd said Papua New Guinea was entering "unknown terrain".
"We of course have been urging calm on the part of all parties," he said of the former Australian colony.