The final result was announced by the Afghan Independent Election Commission Chairperson Hawa Alam Nuristani on Tuesday.
Ghani secured 50.64% of total eligible votes, according to Nuristani. Abdullah Abdullah, the Chief Executive of Afghanistan, came second with 39.51% of the votes.
The results were delayed because of widespread allegations of fraud, which meant that hundreds of thousands of votes had to undergo recounts and an auditing process.
A former academic who previously taught at Berkeley and Johns Hopkins University in the United States, Ghani used to be an American citizen until he gave up his passport to run for the Afghan presidency in 2009.