Former military commander Sitiveni Rabuka was on Saturday confirmed as Fiji's prime minister, after accusing the outgoing government of stoking "fear and chaos" to derail his return to power.
Rabuka replaces the imposing Frank Bainimarama, who toppled the government in a 2006 coup and became prime minister a year later.
The 74-year-old Rabuka said he felt "humbled" as he made his way out of parliament to be sworn in by the country's president.
The two-time coup leader and former prime minister -- nicknamed "Rambo" -- narrowly triumphed over Bainimarama by 28 votes to 27 in a secret ballot held in parliament, speaker Naiqama Lalabalavu announced.
A smiling Bainimarama appeared to accept defeat as he told reporters after the vote: "This is democracy".
A chorus of cars honked in celebration as they drove past the parliamentary building in the capital Suva.
New Zealand Prime Minister Jacinda Ardern congratulated Rabuka in a statement.
"We strongly value Fiji as a close friend and partner as we progress our shared priorities for the region," she said.
Fiji is one of the most populous and prosperous Pacific island nations, and has grown closer to China under Bainimarama.
Rabuka has signalled a willingness to shift away from Beijing in favour of traditional allies Australia and New Zealand.
In a statement Saturday congratulating Rabuka on his win, US President Joe Biden described the two countries as "close partners" collaborating "to advance an Indo-Pacific that is free, open, prosperous, and secure".
The military had been deployed on the streets of Suva as Rabuka and Bainimarama raced to cobble together a coalition government following a deadlocked general election.
Citing unsubstantiated reports of ethnic violence, Bainimarama said the military was needed to maintain "law and order".
But Rabuka -- who served as prime minister between 1992 and 1999 -- said the government was "sowing fear and chaos" and "trying to set the nation alight along racial lines".
Many Fijians feared the government's claims of ethnic violence -- and the subsequent military deployment -- were a pretext for a "creeping coup" designed to keep Rabuka in opposition.
While not an outright autocrat, Bainimarama's government had frequently used the legal system to sideline opponents, silence critics and muzzle the media.
Police last week summoned Rabuka for questioning after he asked the military to step in and help resolve alleged "anomalies" in preliminary election results.
"The way this government has operated, we've been talking about a climate of fear," he said at the time.
"This is how they instil that fear."
Rabuka led two military coups in 1987, which aimed to increase the political influence of Indigenous Fijians, who make up about 60 percent of the country's 900,000 population.
For this reason Rabuka has long been viewed with suspicion by the country's sizable ethnic Indian minority, who were further marginalised in the aftermath.
Incoming deputy prime minister Biman Prasad, a close political ally, has helped to soften Rabuka's image.
Rabuka, a former Fijian rugby international, locked in a coalition deal to form a government on Friday afternoon, after successfully wooing the kingmaker SODELPA party.
SODELPA had earlier chosen Rabuka's People's Alliance over Bainimarama's Fiji First, but that first vote was ruled invalid by the country's election supervisor.
Rabuka could have a difficult time keeping his three-party coalition on the same page.
They hold 29 seats in the 55-seat legislature, yet Rabuka only secured 28 votes -- suggesting one member broke ranks in the secret ballot.
Fiji has been upended by four coups in the past 35 years.