Afghanistan's President Ashraf Ghani appeared to have won a second term Sunday, narrowly scoring an outright win in preliminary polling results, but his main rival immediately vowed to challenge the tally.
After months of political limbo and bitter allegations of fraud and corruption in the September 28 poll, Afghanistan's Independent Election Commission (IEC) said Ghani had won 50.64 percent of the vote.
If it holds, the result is enough for Ghani to avoid a run-off. He easily beat his top challenger, Chief Executive Abdullah Abdullah, who scored 39.52 percent.
Candidates now have three days to file any complaints they may have before final results are announced, probably within a few weeks.
As soon as results were announced, Abdullah's office said in a statement he would contest them.
"We would like to make it clear once again to our people, supporters, election commission and our international allies that our team will not accept the result of this fraudulent vote unless our legitimate demands are addressed," the statement read.
Abdullah lost to Ghani in 2014 in a divisive election that saw the US intervene to broker an awkward power-sharing deal between the two rivals.
Ghani's office did not immediately comment, but the president was due to give an address at 5:00 pm (1230 GMT).
US ambassador to Afghanistan John Bass said it was vital the full electoral process plays out.
"It's important for all Afghans to remember: these results are preliminary. Many steps remain before final election results are certified, to ensure the Afghan people have confidence in the results," Bass wrote on Twitter.
Preliminary results were originally due October 19 but were repeatedly delayed amid technical issues and allegations of fraud from various candidates, particularly Abdullah.
"We, with honesty, loyalty, responsibility and faithfulness completed our duty," IEC chairwoman Hawa Alam Nuristani said.
"We respected every single vote because we wanted democracy to endure."
The protracted limbo between the vote and the preliminary result heaped additional uncertainty on Afghans who already are anxiously awaiting the outcome of talks between the US and the Taliban.
The UN Assistance Mission in Afghanistan (UNAMA), which provided support to electoral authorities, welcomed the announcement of preliminary results and called on the Electoral Complaints Commission to listen carefully to any grievances.
"The ECC has an obligation to adjudicate any complaints it receives transparently and thoroughly so the election process may conclude in a credible manner," UNAMA head Tadamichi Yamamoto said.
The election was meant to be the cleanest yet in Afghanistan's young democracy, with a German firm supplying biometric machines to stop people from voting more than once.
But problems immediately emerged, with allegations of vote stuffing, illegal voting and other fraud coming almost as soon as the polls had closed.
Nearly one million of the initial 2.7 million votes were purged owing to irregularities, meaning the election saw by far the lowest turnout of any Afghan poll.
Ultimately, only 1.8 million votes were counted, a tiny number considering Afghanistan's estimated population of 37 million and a total of 9.6 million registered voters.
Many people stayed away amid Taliban vows to attack polling stations, compounded by voter apathy and despair that any politician can ever improve the lot of the average Afghan.
Thirty-one percent of votes were cast by women, the IEC said.
Abdullah has repeatedly cried foul over 300,000 votes the IEC counted even though his team claims many of these ballots were fake or had been cast outside of polling hours.
His apparent loss to Ghani makes Abdullah a three-time loser and his future in government is uncertain as he has ruled out another power-sharing deal with Ghani.