Gambia's president has agreed to leave after weeks of refusal [File: Carlos Garcia Rawlins/Reuters]

Gambia's new president has said that Yahya Jammeh, who ruled the country for 22 years and refused for weeks to step down after losing the recent election, has finally "agreed to leave".

Writing on Twitter on Friday, Adama Barrow said Jammeh would also leave the country.

"I would like to inform you that Yahya Jammeh has agreed to step down. He is scheduled to depart Gambia today. #NewGambia," he tweeted.

Barrow was sworn-in at Gambia's embassy in Dakar in neighbouring Senegal on Thursday. 

Red carpets were reportedly laid out at the airport in Gambia's capital in what appeared to be preparations for a speech by Jammeh and a departure.

Also on Friday, Gambia's chief of defence forces Ousmane Badjie pledged his allegiance to the country's new president, a major shift as mediation continued to persuade Jammeh to cede power.

Jammeh had rejected Barrow's December 1 election win, despite significant pressure from regional powers and the UN, sparking a major crisis.

READ MORE: Is Gambia on a path to turmoil? 

At least 46,000 people have fled Gambia for Senegal since the start of the crisis fearing unrest, the UN's refugee agency UNHCR said, citing Senegalese government figures.

Celebrations erupted in Banjul, meanwhile, where tensions have run high especially since the declaration of a state of emergency by Jammeh made on Tuesday.

Barrow, a real estate agent turned politician, had flown into Senegal on January 15 to seek shelter after weeks of rising tension over Jammeh's stance.

Exclusive: Al Jazeera interviews Gambia's new president Adama Barrow

West African troops had entered the country to bolster new President Barrow, but military operations were suspended in favour of a final diplomatic push to convince Jammeh to exit peacefully.

In his first media interview with Al Jazeera, Barrow said that he hoped the 15-nation Economic Community of West African States (ECOWAS) could find him a safe haven.

Jammeh started negotiations with ECOWAS on Thursday. He demanded an amnesty for any crimes that he may have committed during his 22 years in power and that he be permitted to stay in Gambia, at his home village of Kanilai.

Those demands were not acceptable, said Marcel Alain de Souza, head of ECOWAS.

Jammeh's continued presence in Gambia would "create disturbances to public order and terrorist movements" he said.

Al Jazeera's Nicolas Haque, reporting from Dakar, said: "A stable Gambia, Barrow told me, has to be without Jammeh in the picture. That's why this news is quite significant for all those that have left the country - 46,000 since January 1 ...  They hope he leaves so they can come back."

Inside Story - Can a showdown be averted in Gambia?

Source: Al Jazeera and news agencies