Troops in the West African country of Guinea-Bissau have freed the interim president and ex-prime minister seized in a coup.
Former PM Carlos Gomes Junior and interim President Raimundo Pereira have been flown to Ivory Coast's commercial capital of Abidjan, officials said.
The coup leaders have also agreed to a 12-month transition to civilian rule, as demanded by regional bloc Ecowas.
The army seized power during a presidential election on 12 April.
The soldiers claimed that Mr Gomes - who was considered the front-runner in the election - planned to reduce the size of the army.
The BBC's John James, in Ivory Coast, says both freed men are due to meet Ivorian President Alassane Ouattara over the weekend, after more than two weeks of detention.
On arrival at Abidjan airport they were welcomed by Ivory Coast's Foreign Minister Daniel Kablan Duncan and African Integration Minister Adama Bictogo, an AFP reporter there said.
Mr Pereira thanked President Ouattara, the current head of Ecowas, for his role in their release.
Earlier, Ecowas leaders agreed to send troops to Guinea-Bissau - and also Mali - following coups in both countries.
Ecowas warned Guinea-Bissau's coup leaders on Thursday that they faced targeted sanctions if they failed to agree to the deployment of troops within 72 hours.
The bloc said it expected both countries to hold presidential elections within the next 12 months.
No elected leader in nearly 40 years of independence has finished their time in office in the former Portuguese colony.
Guinea-Bissau has become a major staging post for gangs smuggling cocaine from Latin America to Europe.