The Papua New Guinea parliament has elected Peter O'Neill as prime minister in an extraordinary sitting in Port Moresby.
Mr O'Neill stood unopposed and won 56 votes.
The election was called after the deputy speaker accepted last week's Supreme Court ruling upholding an earlier judgment that Sir Michael Somare was illegally removed as the country's prime minister last August.
The speaker also disqualified Sir Michael as a member of parliament for missing three consecutive sittings this year.
Sir Michael had taken court action last year after parliament controversially declared the prime ministership vacant and chose Mr O'Neill as head of government.
The judges who ruled that Sir Michael's prime ministership was still valid have in the past week been charged with sedition.
It is not immediately clear if the charges will be upheld as Mr O'Neill and his supporters have now accepted the court ruling that they were an illegal government.
Observers say the legality of today's election may be subject to a challenge because the sitting to choose Mr O'Neill was called after parliament had risen for next month's election.