Burkina Faso’s interim President Michel Kafando has been formally reinstated a week after the military takeover.
The ceremony took place in the capital, Ouagadougou, in the presence of several West African leaders who helped mediate an end to the crisis.
The presidential guard carried out the coup. Its leader Gen Gilbert Diendere admitted to local media that it had been “the biggest mistake”.
“We knew the people were not in favour of it. That is why we have given up.”
The presidential guard (RSP) is loyal to Blaise Compaore, the country’s long-time ruler who was ousted in a popular uprising last year.
They pledged to return to barracks after signing a deal with the regular army on Tuesday to hand back power. The army said it would withdraw from the capital.
Gen Diendere greeted arriving African leaders at the airport earlier on Wednesday, along with the army chief of staff, but did not attend the transfer of power ceremony.
He told reporters hours after Mr Kafando was reinstated that he took “full responsibility” for the coup and was “not afraid to face justice”.
He said he was happy that “we avoided confrontation” but admitted the coup had been a “waste of time and resources… and human lives were lost”.
Coup leader Gen Gilbert Diendere (R) and the army chief Gen Pingrenoma Zagre put on a show of unity at the airport to welcome the West African leaders
Their peace deal was witnessed by Mogho Naba, the traditional ruler of the Mossi ethnic group
The army on Monday had ordered the coup leaders to step down or be ousted by force, raising the spectre of a civil war.
At least 10 people have been killed and more than 100 injured in clashes between the RSP and protesters.
President Kafando also thanked the West African leaders, as they put together a plan to end the crisis at an emergency meeting of the regional bloc Ecowas on Tuesday.
Benin’s President Thomas Boni Yayi, at the ceremony, said efforts must now be focused on efforts to quickly bring free, fair and transparent elections.
It is not clear whether the mediators’ peace plan includes key RSP demands for an amnesty for the coup leaders and the lifting of an electoral ban on those connected to Mr Compaore.