Mr. Jammeh was defeated in December’s election by Adama Barrow but he went on to challenge the results.
But two days after Mr Barrow was sworn in, Mr. Jammeh left on a plane reportedly bound for Guinea.
Mr. Barrow said that he would be returning to his homeland “sooner than later”.
In an interview on Saturday, he said said he wanted to create a truth and reconciliation committee to investigate allegations of human rights abuses during Mr. Jammeh’s time in office.
Mr. Barrow has been in neighbouring Senegal for days and was inaugurated as president in the Gambian embassy there on Thursday.
Troops from several West African nations, including neighbouring Senegal, had been deployed in The Gambia, threatening to drive Mr. Jammeh out of office if he did not agree to go.
Mr. Jammeh’s decision to quit came after talks with the presidents of Guinea and Mauritania.
Guinea’s President Alpha Conde was with Mr. Jammeh and his wife on the plane that left Banjul late on Saturday.
In an address on state television, Mr. Jammeh, who had once said he would rule The Gambia for a billion years, said he would stand down and that it was “not necessary that a single drop of blood be shed”.
In a statement, he said: “I have decided today in good conscience to relinquish the mantle of leadership of this great nation with infinite gratitude to all Gambians. My decision today was not dictated by anything else than the supreme interest of you the Gambian people and our dear country. At a time when we are witnessing trouble and fears in other parts of Africa and the world the peace and security of the Gambia is our collective heritage which we must jealously guard and defend.”
Yahya Jammeh arrived at the airport amid a large convoy of vehicles and throngs of cheering supporters.
He stood on a small platform to hear ceremonial music performed by a military band and then walked down a long red carpet surrounded by dignitaries.
He climbed the steps to the plane, turned and kissed and waved a Koran at those assembled.
After 22 years in power, he left bound for Guinea where it’s believed he will stay before going on to another country.
Soldiers, supporters and dignitaries were emotional as he left – many of them crying. Many others in The Gambia are glad to see the end of what they considered a dictatorship, where there was little respect for human rights or freedom of speech
The details of the arrangements made – or promises offered to persuade Mr. Jammeh to give up power peacefully are not yet known, but there was the real threat of military action from regional states.
He’s the first president to peacefully hand over power in The Gambia since independence from Britain in 1965.
Mr. Jammeh was given an ultimatum to leave office or be forced out by UN-backed troops, which expired at 16:00 GMT on Friday.
The deadline was set by the Economic Community of West African States (ECOWAS), a regional grouping backed by the United Nations.
The group has sent a strong message to the region, and all of Africa, that they stand ready to protect democracy and are willing to send troops to enforce fair election results, says the BBC’s West Africa correspondent Thomas Fessy.
Mr. Jammeh had at first accepted defeat in the election but then reversed his position before declaring a 90-day state of emergency, blaming irregularities in the electoral process.
He finally agreed to handover on the 21st of January, 2017.