Burkina Faso's military has reportedly released the country's interim president after he was detained during a coup that dissolved his government.
The military released a statement on Friday saying that Michel Kafando has been released from military custody.
The move comes after international condemnation and demands for his release.
The interim prime minister was also detained and remains under house arrest.
Kafando, a former UN ambassador, had been chosen as an interim civilian leader after longtime President Blaise Compaore was ousted in a popular uprising last October.
His government had organised national elections for October 11 but members of the military loyal to Compaore took power and arrested Kafando on Wednesday.
Related: Military claims control of Burkina Faso amid unrest
The junta later announced that a military general loyal to Compaore is now in charge.
Senegal's President Macky Sall, the current chairman of the West African ECOWAS bloc, and Benin's President Thomas Boni Yayi were to travel to the capital Ouagadougou on Friday to act as mediators in the crisis and attempt to free the government officials.
On Thursday, heavily armed troops crushed protests in Ouagadougoul.
At least three people were killed and more than 60 injured, according to hospital sources, when members of the presidential guard fired warning shots to disperse crowds and used batons to beat back stone-throwing demonstrators.
The coup leaders' authority did not appear to extend beyond the capital and soldiers stood aside as youths demonstrated in several other cities and towns.
| Why are coups common in Africa?
The protesters had been demanding the release of the interim president and members of his government detained by the presidential guard on Wednesday, and the organisation of elections as scheduled for October 11.
The vote is meant to mark a return to democracy a year after unrest toppled President Blaise Compaore when he tried to extend his 27-year rule.
The uprising became a beacon for democratic aspirations in Africa at a time when long-term rulers from Rwanda to the Democratic Republic of Congo are seeking to scrap term limits.
General Gilbert Diendere, the coup leader who for three decades was Compaore's shadowy chief military adviser, said the trigger for the coup was a proposal this week by the transitional authorities to dismantle the presidential guard.
He said the underlying cause of the military power grab was fear of instability after the transitional government barred Compaore's supporters from contesting the polls next month.
"There may be some kind of sanctions to face but we will ask the international community to be understanding of Burkina Faso," Diendere told Reuters.
| The uprising became a beacon for democratic aspirations in Africa [AP]