Ashraf Ghani has been sworn in as the president of Afghanistan in the war-torn country's first democratic transfer of power.

Ghani and his two deputy presidents were sworn in by the chief justice of Afghanistan during the inauguration ceremony in the capital Kabul.

The event was attended by top leaders including outgoing president Hamid Karzai.

Karzai said he was proud of the peaceful transfer of power and wished the new administration well.

Ghani's electoral rival Abdullah Abdullah has also been sworn-in as chief executive, a post similar to that of a prime minister.

Ghani was a World Bank official and a former finance minister and spent long years outside Afghanistan.

The swearing-in brings to an end a prolonged political stand-off. Last week, the two sides entered into a power-sharing agreement.

On the eve of the ceremony, Karzai delivered a farewell address to the nation in which he said: "Our nation deserves a better life. Sooner or later, there will certainly be peace in the country. All of our efforts are to accelerate that process. When I first came to office we didn't have a flag or currency. We were the object of foreign agendas. We were homeless in our own country."

"I am proud to have worked toward bringing the nation together to live under one flag in their shared homeland. I am proud to have worked toward rebuilding the nation that our ancestors had built. I am proud to see kids going to school all over the country and singing the national anthem with pride and joy every day."