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".
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.
Analysis: Maud Jullien, BBC Africa, Ouagadougou:
Is this the end of the crisis in Burkina Faso? The president has been officially reinstated but the crucial issues that prompted the coup remain unresolved and questions remain.
- Will the presidential guard be disbanded? They led the coup as they were unhappy about being integrated into the regular army
- Will members of the former ruling CDP party of ousted ruler Blaise Compaore be able to run in the next election? They had been banned.
After the ceremony, Gen Gilbert Diendere went into a closed-door meeting with the West African leaders.
He has faced national and international pressure over the past few days to hand back power, but he still has the most powerful troops in the country behind him.
These 1,200 well-armed and well-trained men are unlikely to accept surrender or the exclusion of the CDP candidates.
Meanwhile, the civil society and protesters say they will not accept amnesty for those that led the coup.
The BBC's Maud Jullien in Ouagadougou says President Kafando thanked the West African leaders, to cheers from the audience of politicians and civil society leaders.
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.
Earlier on Wednesday, Mr Kafando said he was not fully committed to the plan.
"We are proud of the mobilisation and fearlessness of the people of Burkina Faso, in particular of its youth, whose determination has stopped" the coup succeeding, Mr Kafando said.
"I salute the international community for having rejected unequivocally this action.
"Regarding the Ecowas proposals for a solution to the crisis, it is obvious that we will only commit to them if they take into account the will of the Burkinabes."
He had been detained during a cabinet meeting last Wednesday.
The agreement overnight between the RSP and army was signed in front of the country's most influential leader, Mogho Naba.
Regular army troops had entered Ouagadougou on Monday vowing to retake it.
The deal ended the 24-hour stand-off and defused the tension ahead of the African leaders' visit.