BANJUL/DAKAR (Reuters) - Gambia’s longtime ruler Yahya Jammeh, who refused to accept his election defeat last month, has agreed to go into exile, a senior adviser to new President Adama Barrow said on Friday, but talks to finalise the deal were holding up his exit.

The swearing-in ceremony at the inauguration of Gambia President Adama Barrow at the Gambian embassy in Dakar, Senegal January 19, 2017, is seen in this handout photo provided by Office of the Senegal Presidency. REUTERS/Office of the Senegal Presidency/Handout

Regional armies, who entered Gambia late on Thursday, were meanwhile poised to remove him by force if required, as even his army chief, who had stood beside the former coup leader, recognised his rival Barrow as commander-in-chief.

West African leaders Alpha Conde of Guinea and Mauritania’s President Mohamed Ould Abdel Aziz travelled to the capital Banjul on Friday to allow Jammeh one last chance to cede power peacefully.

“I can assure you that he has agreed to leave,” Mai Ahmad Fatty, Barrow’s special advisor, told Reuters in Senegal’s capital Dakar. He could not say where Jammeh would go into exile.

Barrow, who won the Dec. 1 poll by a slim margin, was sworn into office at Gambia’s embassy in Dakar on Thursday and immediately called for regional and international support.

West African militaries announced soon after that they had crossed into Gambia, which is almost completely surrounded by Senegal.

“The rule of fear has been banished from Gambia for good,” Barrow told a crowd gathered at a Dakar hotel on Friday. “To all of you forced by political circumstances to flee our country, you now have the liberty to return home.”

Gambia’s army chief General Ousman Badjie, who had been perhaps the last remaining pillar of support for Jammeh, said he would welcome, not fight, the regional force.

“We are going to welcome them with flowers and make them a cup of tea,” he told Reuters. “This is a political problem. It’s a misunderstanding. We are not going to fight Nigerian, Togolese or any military that comes.”

Slideshow ( 13 images )

The military operation was halted late on Thursday to give mediation a chance.

A midday deadline was extended on Friday as negotiations, which diplomats said were focusing on a deal that would grant Jammeh immunity from prosecution, continued.

FINAL ACT

One regional diplomat said the delegation was planning to spend the night in Banjul and Jammeh was looking for “extremely solid guarantees” before leaving.

“There is a real possibility this could work. I don’t think he is going the (Saddam) Hussein route,” he said, referring to the Iraqi leader who was arrested in 2003 following an invasion, then tried and hanged.

Jammeh, in power since a 1994 coup, initially conceded defeat to Barrow before back-tracking, saying the vote was flawed and demanding a new ballot.

During his 22-years in power, Jammeh, who once vowed to rule Gambia “for a billion years”, has been accused by rights groups of torturing and killing perceived opponents. And some Gambians were angered by the prospect of granting him immunity.

“I don’t want that man to escape punishment from us,” said Lamin Darboe, 35, a Gambian shopkeeper who was present at Barrow’s speech in Dakar on Friday. “Wherever he moves to we’ll follow him there and grab him.”

Late on Thursday, Jammeh dissolved the government - half of whose members had already resigned - and pledged to name a new one.

His estate, located almost on the border with Gambia’s sole neighbour Senegal, was heavily fortified on Friday, witnesses said.

ECOWAS says its intervention, dubbed Operation Restore Democracy, involves 7,000 troops backed by tanks and warplanes. Its forces entered Gambia from the southeast, southwest and north.

Reuters witnesses saw a fresh convoy of more than a dozen trucks loaded with heavily armed Senegalese soldiers arrive at the border near the Senegalese town of Karang on Friday afternoon.

The size of Gambia’s army is unclear, but estimates range from 800 up to 2,500 soldiers.

The U.N. refugee agency UNHCR said about 45,000 people, mainly children, have fled to Senegal since Jan. 1 amid growing fears of unrest.

Thousands of tourists, who’d flocked to the popular beach holiday destination for a break from the harsh European winter, also left this week.

(This story has been refiled to add Dakar to dateline)