(CNN) -- The head of the Papua New Guinea military has been freed from detention by rebel soldiers, the Australian government said Thursday, as an attempted mutiny appeared to unravel.
Yaura Sasa, a rebel commander, had earlier claimed that he had seized control of the Papua New Guinea Defense Force, confining its leader, Brig. Gen. Francis Agwi, and another senior officer to their residences.
The Australian government -- which has a significant presence in Papua New Guinea, a country it used to administer -- said that Agwi had subsequently been released. The Australian Department of Foreign Affairs and Trade said in a statement that it was important that "order is fully restored" in the Papua New Guinea armed forces.
The unrest in the military came amid controversy in Papua New Guinea over who the rightful prime minister is.
Sasa claimed he had taken control of the defense force in order "to restore the integrity and respect for the constitution and judiciary."
He called for the immediate implementation of "the supreme court decision relating to Sir Michael Somare's position as the prime minister of Papua New Guinea."
Somare has been a key figure in the Papua New Guinea political scene over the past four decades, helping to lead the country to independence in the 1970s. After being in and out of office over the years, he was elected prime minister in 2007. But he lost his position last year while recovering from heart surgery in Singapore.
He now apparently contests the legitimacy of the current prime minister, Peter O'Neill.
In a news briefing, O'Neill described the events at the military barracks as "completely unnecessary." He blamed Somare for the disturbances.
"We condemn the actions of particularly the Somare faction of our Parliament for creating such an environment where instability within the country and within the disciplined forces are being created," he said.
The Australian government said O'Neill had told Ian Kemish, the Australian high commissioner in the capital Port Moresby, that the authorities "were taking steps to manage the situation" in the military barracks.
CNN's Jethro Mullen contributed to this report.