The Pacific nation of Samoa is on the verge of swearing in a new prime minister for the first time in more than two decades, and its first female head of government.
The country has been in a five-week political deadlock since the April 9 election, when the opposition Fa'atuatua i le Atua Samoa ua Tasi (FAST party) and the incumbent Human Rights Protection Party (HRPP) won 25 seats each.
HRPP has dominated Samoa's politics for nearly 40 years, and its leader, 75-year-old Prime Minister Tuilaepa Sailele Malielegaoi, has held office for more than 22 years - making him one of the world's longest-serving leaders.
But FAST, which was formed only last year in protest of the government rushing several bills into law, said it now had the majority to lead, after Samoa's top court handed down two key rulings in its favour.
The judgements mean that FAST's leader, Fiame Naomi Mata'afa, who was Samoa's deputy prime minister until she defected from the government last year, is on track to become the new prime minister.
"I'm feeling very thankful," Fiame told the ABC.
"I think today's victor[ies] are victories of the law and the rule of law that we've been advocating for."
Political twists and turns
Several weeks after Samoans went to the polls, the country's Electoral Commission ruled that not enough women were elected to Parliament in order to fulfil the country's minimum 10 per cent quota for female MPs.It awarded the HRPP an extra seat in a late-night announcement.
The shock decision gave the incumbent HRPP 26 seats, and almost secured Tuilaepa's power for a further five years.
But at the same time, the sole independent MP to win a seat, Tuala Tevaga Iosefo Ponifasio, confirmed he would join the opposition FAST party, leaving each party deadlocked again at 26 seats each.
Both parties launched legal challenges but on May 4, Samoa's Head of State, Afioga Tuimalealiifano Vaaletoa Sualauvi, who was appointed by the incumbent Prime Minister, called for fresh elections to be held this Friday.
"I am of the firm belief that given the facts, that there is no majority to form parliament, that it is in the best interest of Samoa that fresh elections be called to allow people a second opportunity to elect their 17th parliament," he said.
But critics argued that decision was "unconstitutional" and the opposition claimed the government was trying to retain power through "trickery".
Samoa's Supreme Court today agreed, ruling that the country's constitution does not give the Head of State the authority to void the results of the April 9 general elections and call new elections.
As a result, it found the results of the April 9 poll were valid and lawful.
An earlier ruling today found the appointment of the government's extra female lawmaker was unconstitutional and invalid, giving the FAST a one-seat majority.
"The unanimous verdict reached by a panel of justices of the Supreme Court on Monday now gives the Fa'atuatua ile Atua Samoa ua Tasi (FAST) Party the majority to form government with 26 seats to their rivals, the Human Rights Protection Party's 25," the FAST party said on social media.
The Supreme Court has ordered Samoa's Parliament to sit within 45 days of the April 9 election, which is Monday, May 24.
The ABC has sought comment from the HRPP and Samoa's Electoral Commissioner.