Thursday 26 January 2012 12.07 EST
First published on Thursday 26 January 2012 12.07 EST

A military coup has been averted in Papua New Guinea after government troops regained control of an army barracks, the country's prime minister said.

Analysts warned, however, that peace may not last long, as the failed mutiny risks escalating political tensions in the lead-up to general elections this year.

Soldiers loyal to the former prime minister Sir Michael Somare stormed the Port Moresby barracks early Thursday morning, demanding the resignation of the prime minister, Peter O'Neill, and putting his highest military commander, Francis Agwi, under house arrest.

"The commander is now released. He's not under house arrest," O'Neill told journalists. "As a result, the government has taken full control of the defence headquarters."

The mutiny is the latest development in a longstanding saga involving O'Neill and his political rival Somare, who also claims to be the rightful head of this mineral-rich South Pacific nation.

Somare served as Papua New Guinea's first prime minister after independence from Australia in 1975, and again in 2002 until August 2011, when he was deposed by parliament while receiving medical treatment abroad.

The country's supreme court ruled last month that Somare had been illegally removed and called for his reappointment.

Soldiers working on behalf of Somare told O'Neill on Thursday that he had seven days to fulfil a supreme court order reinstating Somare as prime minister or be forced to suffer "actions … uphold[ing] the integrity of the constitution".

The prime minister rejected calls for his resignation, saying: "This government does not answer to one man calling on us to recall parliament."

He invited those doubting his leadership to introduce a vote of no confidence in parliament, "and if they succeed I will resign".

Elections are due in Papua New Guinea in mid-2012 but could be called earlier, O'Neill said, adding that parliament would resume on 14 February, as scheduled.

While peace has been restored in the nation of 6.8 million, it may be shortlived, said Neil Ashdown, Asia-Pacific analyst at IHS Global Insight.

"The failed military mutiny in Papua New Guinea risks significantly escalating the political standoff in the country," he said. "In the short term, there is the possibility of recriminations against military and political figures seen as linked to the failed mutiny."

The deputy prime minister, Belden Namah, earlier accused Somare of using "rogue soldiers to pursue his own greed and selfishness" and appeared on television to tell the retired colonel Yuara Sasa, who staged the mutiny, that he could be charged with treason – a crime carrying the death sentence.

"Somare has now lost the total respect of the country he fought for independence [for]," Namah told Australian Associated Press.

"I want to say this to Somare: you have lost your mind. You have lost total control of yourself ... You have lost sanity."

Somare has not made any statement regarding the mutiny, but his daughter and media spokeswoman Betha reportedly told journalists that Somare and his 20-odd parliamentary supporters were behind the coup.

Julia Gillard, the Australian prime minister, condemned the mutiny, saying: "The military has no place in PNG politics". She called for the situation to be resolved peacefully and quickly.

Papua New Guinea is home to 800 ethnic groups, and crime and violence are extremely common. In 2002, about 100 people were reportedly killed during election-related skirmishes.

Domestic flights between Port Moresby, the capital, and the cities of Lae, Vanimo, Kiunga and Wewak have been suspended indefinitely, according to the UK Foreign Office, which has advised British nationals in the country to exercise extreme caution in public areas and ahead of the election.