Moments after he took the oath, he swore in his election challenger, Abdullah Abdullah, as chief executive, fulfilling a political pledge he had taken to share power and defuse election tensions which had threatened to spark violence between the country’s north and south.
In his first speech, Mr Ghani Ahmadzai called on the Taliban and other militants to join the country’s political process and lay down their weapons.
However, extremist violence killed at least 12 civilians and police officers as foreign forces prepare to withdraw from the country at the end of the year.
“We are tired of war,” Mr Ghani Ahmadzai said in a televised address. “Our message is peace, (but) this doesn’t mean we are weak.”
Mr Ghani Ahmadzai, a former World Bank official and Afghan finance minister, wore a dark black turban popular in the country’s south as he swore in his two vice presidents and then Mr Abdullah.
Mr Abdullah, a former foreign minister, spoke first and thanked Mr Karzai for his service and the people of the country for casting votes in the millions despite the threat of attack from Taliban militants who tried to thwart the election process.
“We are committed as one in the national unity government,” he said. “Our commitment will be fulfilled together as unified team to create national unity.”
Mr Ghani Ahmadzai then congratulated Mr Karzai on a peaceful and democratic transition of power, and thanked Mr Abdullah for making the national unity government possible. The new president also promised to confront the country’s endemic corruption.
“We want to be held accountable. I am your leader but I am no better than you. If I make mistakes, you should hold me accountable,” he said.
Mr Karzai - the only president Afghanistan and the West have known since the invasion - smiled broadly as he greeted his guards upon entering the palace. He has said he is glad to be stepping down after more than a decade of what the US ambassador recently said was one of the most difficult jobs in the world.
Mr Ghani Ahmadzai’s inauguration caps a nearly six-month election season that began when ballots were first cast in April. A run-off election in June between him and Mr Abdullah stretched on for weeks as both sides levelled charges of fraud.
The United Nations helped carry out what it said was the most thorough recount in its history, a count that reduced Mr Ghani Ahmadzai’s share of the vote from 56% to 55%, but still gave him the win.
But the real power struggle was taking place in marathon talks between the two sides, often brokered by US Secretary of State John Kerry and other American officials. The political deal agreed by the two sides created the new position of chief executive that Mr Abdullah will now fill.
The inauguration took place eight days after the political deal was signed between Mr Ghani Ahmadzai and Mr Abdullah. Though Mr Kerry played a big role in the political deal, the short notice of the inauguration date and events elsewhere in the Middle East did not allow him to attend. Instead, the US was represented by John Podesta, counsellor to President Barack Obama. Other notable guests included Pakistan President Mamnoon Hussain and Indian Vice President Mohammad Hamid Ansari.
US officials have said they expect Mr Ghani Ahmadzai to sign a security agreement shortly after his inauguration to allow about 10,000 American troops to stay in the country after the international combat mission ends on December 31.
Even as the inauguration unfolded in the heavily guarded presidential palace, two bomb attacks took place on the road connecting the country’s main airport with the palace. One roadside bomb did not result in any deaths or injuries, but a second attack about half a mile (1km) from the airport by a suicide bomber killed six or seven people, police officer Abdul Latif said.
A bigger attack took place in the eastern province of Paktia. Police Captain Mohammed Hekhlas said a car bomb exploded near a government compound as gunmen attacked, sparking a gun battle that killed seven Taliban militants. Another police official, who gave his name as Azimullah, said four police officers and two civilians also were killed.
For Afghans watching the inauguration, the threat of violence and insecurity remained one of their top concerns.
“I hope Ashraf Ghani Ahmadzai can bring peace and the rule the law in Afghanistan as former Afghan President Hamid Karzai could not bring peace,” said Abdul Rahman, a 30-year-old police officer. “Our people have been suffering from the instability and poverty.”