Fiji's opposition on Thursday demanded counting be stopped in the coup-prone nation's bitterly-fought general election, alleging serious "anomalies" that put the legitimacy of the vote in doubt.

Voters across the chain of 300-plus South Pacific islands on Wednesday cast their ballots to elect a government for the next four years.

Two former military leaders are vying to be prime minister -- incumbent Frank Bainimarama who came to power in a putsch 16 years ago, and Sitiveni Rabuka, a two-time coup leader nicknamed "Rambo".

Fiji has endured four coups since 1987 and this year's election was a test of its fledgling democracy.

Voting day passed without major incident, but the ongoing count has been marred by a late-night "glitch" that hid the tally from public view for four hours.

Rabuka had led the polls in very early results, lifting supporters' hopes and raising the prospect of the first peaceful transition of power in two decades.

But when the system was restored just before dawn on Thursday, he was trailing Bainimarama by a significant margin.

After tense discussions with his staff at campaign headquarters, Rabuka told AFP he was planning a legal challenge.

"We will pursue every avenue available to us to make sure that the people are not denied their right of electing their government," he said, with a copy Fiji's constitution close at hand.

He and three other opposition leaders then raised the stakes further, threatening to boycott the next parliament if their demands for a halt to the count and an "urgent forensic audit" are not met.

Rabuka said he was also considering writing to the military to ensure the election was fair -- but sought to assure the country that there "will not be a coup".

Vote organisers have called the incident an "anomaly", and pointed to provisional results that most observers agreed were improbable.

First returns showed a handful of little-known politicians gaining thousands of votes and polling well ahead of the major parties.

Fijian Elections Office boss Mohammed Saneem dismissed allegations of ballot rigging as "conspiracy theories".

But Rabuka and the three other opposition leaders are not convinced.

"We are fed up with these rigged elections," Fiji Labour Party leader and former prime minister Mahendra Chaudhry told reporters.

Bainimarama, the media-shy ex-commodore who won elections in 2014 and 2018, has so far been silent on the controversy.

The 97 members of the Multinational Observer Group present in Fiji to oversee vote counting have also avoided weighing in.

Nervous wait

Pacific analyst Tess Newton Cain said the glitch "may undermine confidence in the elections as a whole".

"It will quite likely undermine confidence in the office of elections, and Saneem as supervisor," added Newton Cain, who is Project Lead at Griffith University's Pacific Hub.

Opinions were split among voters at the vast open-air market on Suva's waterfront.

Rabuka supporter Jone Nheamauto encouraged the challenge and said he did not "trust" the electoral system.

Pravin Lal, 56, said he was happy to continue with the same government.

Final results are not expected until Sunday and may yet be further delayed, but partial tallies showed a tight race.

Bainimarama's Fiji First party held around 45 percent of the vote, with more than half of the country's 2,071 polling stations counted.

Rabuka's People's Alliance and its coalition partner -- the National Federation Party -- had just under 42 percent between them.

Another potential coalition party is polling just under the five percent threshold to take a seat in parliament.

That fracturing of the opposition could once again deliver Bainimarama victory.

The result of the election holds significance well beyond Fiji.

Rabuka has signalled that Fiji -- one of the most prosperous and influential nations in the South Pacific -- could loosen its ties with China if he is elected.

Fiji has grown closer to Beijing under Bainimarama, who used a "look north" policy to stabilise the economy after Australia and New Zealand hit the country with heavy trade sanctions in retaliation for his 2006 coup.