Ashraf Ghani has won a second term as president of Afghanistan, the country’s independent election commission announced, but his closest opponent refused to recognise the result, declaring himself winner and potentially endangering peace negotiations with the Taliban.

The Taliban also rejected Mr Ghani’s win, further putting into question a US peace plan that calls for a reduction in violence followed by a more permanent agreement expected to be signed on February 29 between Washington and the Taliban.

That agreement would pave the way for US troops to return home, ending America’s longest war, and trigger negotiations between Afghans on both sides of the conflict.

The bickering in Kabul and Mr Ghani’s surprise suggestion that the Taliban participate in elections would seem to throw a spanner into peace plans announced last weekend at the Munich Security Summit.

The election commission said Mr Ghani won 923,592 votes, or 50.64%, in the troubled election that took place last September 28. The country’s chief executive, Abdullah Abdullah, received 720,841 votes, or 39.52%.

The two men head a fragile national unity government put together under US pressure after both leaders claimed victory in 2014 elections.

Abdullah Abdullah
Abdullah Abdullah (Rahmat Gul/AP)

Following the announcement of the results, Mr Ghani appeared among supporters in Kabul, where he emphasised the importance of peace talks with the Taliban, saying his winning team will bring peace to the country.

“Its time to make Afghanistan united,” he said, urging the insurgent group to participate in the democratic process without referencing the peace agreement he supported in Munich.

He pointed to candidate Gulbuddin Hekmatyar, who received 3.5% of the vote, as an example of a former militant to has embraced democracy. Mr Hekmatyar was a US-declared terrorist until he signed a peace agreement with Mr Ghani in late 2016.

“I congratulate him and he did a good job. We ask the Taliban as well to come and participate in elections,” Mr Ghani said.

Mr Abdullah, in comments to supporters broadcast by media outlets, said he considered the election results “illegal”.

“We are going to establish an inclusive government,” he said.

Election results were repeatedly delayed amid accusations of misconduct, fraud and technical problems with counting ballots. The final vote tally was originally due to be announced on November 7.

Hawa Alam Nuristani, head of the national election commission, said previously that 1.8 million Afghan citizens voted in the election out of 9.6 million eligible voters.

On election day, many Afghans found incomplete voters’ lists, unworkable biometric identification systems aimed at curbing fraud, and in some cases hostile election workers.

The election commission tried to launch a ballot recount in November but Mr Abdullah halted the attempt, saying he would not let his observers participate. Thousands of his supporters rallied against what they said were fake ballots and the controversial recount had seemed set to favour Mr Ghani.

In December, Mr Abdullah agreed to allow a ballot recount in provinces where his supporters had stopped the process.

The government’s push to hold the vote had been controversial. In an interview with the Associated Press before the election, former president Hamid Karzai warned the election could be destabilising for the country at a time of deep political uncertainty.

Tuesday’s result came days after US defence secretary Mark Esper announced a truce between the US and the Taliban that could lead to the withdrawal of American troops from the country.

Mark Esper, Mike Pompeo and Ashraf Ghani
Mark Esper, Mike Pompeo and Ashraf Ghani (Andrew Caballero-Reynolds/AP)

The Taliban called the election a “fraud” and has maintained that the Afghan government is a “puppet” of the US.

“After the end of the invasion the Muslim people of Afghanistan will decide about their internal issues and will adopt their political faith,” the statement said.

Mr Ghani first ran for president in 2009, capturing barely a quarter of the votes. He ran again in 2014 in what was considered a deeply flawed and corrupt exercise.

He was born on May 19 1949, and holds a doctorate in anthropology from Columbia University after going to the US as a high school exchange student.

Except for a brief teaching stint at Kabul University in the early 1970s, he lived in the US where he was an academic until he joined the World Bank as a senior adviser in 1991.

He returned to Afghanistan after 24 years when the Taliban were ousted by the US-led coalition.

He was head of Kabul University until he joined Mr Karzai’s government as finance minister. In 2010 he led the lengthy process to transfer security of the country from US-led coalition forces to the Afghanistan National Security Forces, which took effect in 2014.