Follow us on Twitter and Instagram to stay connected
Afghanistan's Ghani headed for second term: initial results
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.
A jubilant Ghani gave a televised address, shouting triumphantly while flanked by his two vice presidents. He stopped short of declaring himself winner, but said the election results were a "victory" for all of Afghanistan.
"A government worthy of this great nation will be built," Ghani said.
Candidates now have three days to file any complaints before final results are announced, probably within weeks. Abdullah said he would contest the vote.
"The election commission has unfortunately sided with the fraudsters," Abdullah said in a televised address, when he also demanded a recount in provinces across Afghanistan.
"There is no doubt that we are the winners of the election based on the clean votes of the people," he added.
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.
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 originally due October 19 were repeatedly delayed for what the IEC said were technical issues. Various candidates, particularly Abdullah, alleged fraud.
Observers and candidates have blasted the IEC over its handling of the count and its repeated disregard of the electoral calendar.
The Transparent Electoral Foundation of Afghanistan, an independent watchdog, said the IEC needs to share all information about how it reached its numbers and break down data by polling centre.
IEC chairwoman Hawa Alam Nuristani said her agency acted with "honesty, loyalty, responsibility and faithfulness".
"We respected every single vote because we wanted democracy to endure," she said.
Many people had stayed away from the vote. Taliban vows to attack polling stations compounded voter apathy and despair that any politician could ever improve the lot of the average Afghan.
On the streets of Kabul after the results were announced, reaction was muted. Few people celebrated or protested.
Anxious Afghans
The protracted limbo between the vote and the preliminary result heaped additional uncertainty on Afghans who are already anxiously awaiting the outcome of talks between the US and the Islamist extremist 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.
ECC chairwoman Zuhra Bayan Shinwari said candidates and their supporters should wait for final results to be announced.
"We are committed to reviewing all the complaints according to the law," she said.
The election was meant to be the cleanest yet in Afghanistan's young democracy.
A German firm supplied biometric machines to stop people from voting more than once. But allegations of vote stuffing, illegal balloting and other fraud came almost as soon as the polls had closed.
Read more: CIA-backed 'death squads' accused of Afghanistan 'war crimes'
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.
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.
Thirty-one percent of votes were cast by women, the IEC said.
Abdullah's 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 the president.