A protester holds a loaded slingshot in Burkina Faso's capital, Ouagadougou, on Thursday.
(CNN)Elements of Burkina Faso's military declared they were in control of the nation after presidential guards stormed a Cabinet meeting and seized the President and the Prime Minister -- days before the general elections.
Guards detained interim President Michel Kafando and other government ministers during the raid in the capital Wednesday, the United Nations said.
It's unclear where the guards took the President, Prime Minister Isaac Zida and the other officials.
Hours after their detention, an unidentified military official took to the airwaves Thursday and said the group, now calling itself the National Council for Democracy, "decided to put an end to the deviant transitional regime."
The official announced that the country's new leader would be a former general, Gilbert Diendere. He was an adviser to former President Blaise Compaore, who stepped down under pressure by protesters in 2014 after ruling for 27 years.
The interim government failed to establish a "democracy based on consensus," the military official said on national television.
The official highlighted a series of steps the military is undertaking that include removing the transitional president from office, dissolving the government and forming a broad coalition that will focus on policies that will lead to inclusive elections.
Demonstrators gathered outside the presidential palace in the capital, Ouagadougou, on Thursday in apparent opposition to the takeover.
Soldiers fired guns into the air in an apparent effort to contain the crowd, said Mathatha Tsedu, director of the journalists' trade group South African National Editors Forum, who was in the city for a conference.
The United Nations condemned the leaders' detention.
"This incident is a flagrant violation of Burkina Faso's constitution and transitional charter," U.N. chief Ban Ki-moon said in a statement. "The United Nations stands firmly behind the transitional authorities and President Kafando."
French President Francois Hollande appealed for the release of the leaders and the reinstatement of the transitional authorities.
Days before the raid in Ouagadougou, a commission had recommended the disbanding of the presidential guard unit, which is loyal to Compaore, the former president.
Protesters toppled Compaore last year after he expressed a desire to extend his 27-year rule. He stepped down after days of mass protests and the military briefly took over before Kafando was appointed.
Burkina Faso is scheduled to hold general elections on October 11.
CNN's Margot Haddad, Robyn Kriel, Christian Purefoy and Vasco Cotovio contributed to this report