Burkina Faso's army said on Monday it had ousted President Roch Kabore, suspended the constitution, dissolved the government and the national assembly, and closed the borders.
The announcement, signed by Lieutenant Colonel Paul-Henri Sandaogo Damiba and read by another army officer on state television, said the takeover had been carried out without violence and that those detained were at a secure location.
The statement was made in the name of a previously unheard of entity, the Patriotic Movement for Safeguard and Restoration or MPSR, its French language acronym.
"MPSR, which includes all sections of the army, has decided to end President Kabore's post today," it said.
It cited the deterioration of the security situation and what it described as Kabore's inability to unite the nation and effectively respond to the challenges it faces.
The army broadcast came after two days of confusion and fear in the capital Ouagadougou, where heavy gunfire erupted at army camps on Sunday, with soldiers demanding more support for their fight against Islamist militants.
Kabore's whereabouts were unknown on Monday after heavy gunfire was heard in the area around his residence overnight.
Earlier, Kabore's party said he had survived an assassination attempt, but gave no details.
Before the army statement, the African Union and the West African bloc ECOWAS both condemned what they called an attempted coup in Burkina Faso, saying they held the military responsible for Kabore's safety.