Papua New Guinea's government is in crisis, with two men claiming to the be the legitimate prime minister in a row that has embroiled the country's supreme court and governor general.

Veteran leader Sir Michael Somare was reinstated as prime minister by the country's highest court on Monday after he had been removed and replaced by rival Peter O'Neill while out of the country having medical treatment.

O'Neill has refused to give up power despite the court order and the recognition of Somare's cabinet by the governor general, Sir Michael Ogio. O'Neill's MPs have continued to pass legislation recognising him as leader.

The battle escalated when MPs backing O'Neill stormed the governor general's gates a day after the supreme court ruling that Somare's removal and O'Neill's election by parliament in August was unconstitutional. "We are unarmed and we're the legitimate government," the Australian Broadcasting Corporation quoted the MPs as telling police.

Somare said on Wednesday that his cabinet had been sworn in by Ogio, who represents PNG's head of state, Queen Elizabeth II.

Somare insisted he did not need to be sworn in himself because the supreme court had already reinstated him as prime minister. "It is regretful that all of government was put on hold but this situation has been diffused by the swearing-in today of my cabinet," Somare said.

The crisis continued on Wednesday, with MPs loyal to O'Neill passing a motion ordering Ogio to swear in O'Neill as prime minister. O'Neill could not be reached for comment but on Tuesday he said he had met with Ogio briefly after the march to the official residence in the capital, Port Moresby.

The supreme court's 3-2 decision on Monday that ruled O'Neill's election unconstitutional came after O'Neill's government passed a series of retroactive laws legalising its decision to dump Somare from office while he was in Singapore recovering from a heart condition.

One of Somare's first acts when the supreme court ordered his return to power was to reinstate the former police commissioner Fred Yakasa and oust O'Neill's appointee, Tom Kulunga. Both police chiefs were present at the governor general's home and held discussions with MPs loyal to O'Neill.

Somare has based himself at the Ela Beach Hotel, where he has set up a cabinet made up mostly of ministers from his previous government.

Somare had been in Singapore for five months between late March and 6 September, when he returned to parliament after three heart operations.

Kevin Rudd, the foreign minister in neighbouring Australia, said the former Australian territory had entered uncharted waters.