Nigerien soldiers appeared on the country's national TV station on Wednesday to announce that the President and government had been removed from power, shortly after African organisations reported an attempted coup.
The US said the rebelling soldiers had detained President Mohamed Bazoum, who was democratically elected.
Col Amadou Abdramane said the country's defence and security forces decided to "put an end to the regime that you know due to the deteriorating security situation and bad governance", Reuters reported.
He also announced that a nationwide curfew had begun, while the country's borders were shut.
Earlier on Wednesday, Niger's presidency said on Twitter that members of the elite guard unit engaged in an “anti-Republican demonstration” and unsuccessfully tried to obtain support from other security forces.
It said Mr Bazoum and his family were doing well but that Niger's army and national guard “are ready to attack” if the guards involved did not back down.
The commissions of the African Union and the Economic Community of West African States described the events as an effort to unseat Mr Bazoum.
He was elected President two years ago in the nation's first peaceful, democratic transfer of power since its independence from France in 1960.
Mr Bazoum's government has made Niger a key western partner in the fight against Islamist extremism in Africa's Sahel region.
“We strongly condemn any effort to detain or subvert the functioning of Niger’s democratically elected government, led by President Bazoum,” White House National Security Adviser Jake Sullivan said.
“We specifically urge elements of the presidential guard to release President Bazoum from detention and refrain from violence.”
Streets surrounding the presidential palace in the capital, Niamey, were blocked off on Wednesday, as were some government ministries.
In the early evening, hundreds of people chanting "No coup d’etat” marched in support of Mr Bazoum.
Rounds of gunfire that appeared to come from the presidential palace dispersed the demonstrators and sent people scrambling for cover, AP reported.
“We are here to show the people that we are not happy about this movement going on; just to show these military people that they can’t just take the power like this,” protester Mohammed Sidi said.
“We are a democratic country, we support democracy and we don’t need this kind of movement.”
From Ethiopia’s capital, the African Union Commission’s president, Moussa Faki Mahamat, said he had been told “of an attempt by certain members of the military to undermine the stability of the democratic and republican institutions in Niger, which is tantamount to an attempted coup d’etat.”
Mr Mahamat said the soldiers at the presidential palace were “acting in total betrayal of their republican duty".
The news presenter for the state Office of Radio and Television of Niger reported that a coup attempt was under way in the capital and the situation remained confusing.
The programme mentioned the demonstration in Niamey “to call for the freeing of the President”, but then moved on to other topics.
A source close to the President told AP the guards surrounded Mr Bazoum’s house when he and his wife were inside on Wednesday morning and that negotiations were under way between the parties.
Within hours, there was a military build-up outside the headquarters of the state radio and television networks.
Pickup trucks mounted with machineguns lined the roads to both buildings, with members of the army and national guard waving cars through.
The streets of Niamey were bustling as usual, with many residents refusing to discuss the situation until there was more clarity.
Some international security forces in the country were ordered into lockdown. The UN said its 1,500 staff members in Niger were safe but had to suspend their regular work.
UN Secretary General Antonio Guterres "condemns in the strongest terms any effort to seize power by force and to undermine democratic governance," his spokesman Stephane Dujarric said in a statement.
He also “calls on all actors involved to exercise restraint and to ensure the protection of constitutional order".
Mr Guterres spoke with Mr Bazoum to express his full support and solidarity.
France said on Wednesday that it condemned any attempt to seize power through violence in Niger.
Foreign Ministry spokeswoman Anne-Claire Legendre said Paris was watching the situation carefully but "condemned attempts to take power by force".
Ms Legendre said France joined African Union calls to restore the integrity of democratic institutions.
The UK government said it condemns any attempt to undermine stability and democracy in Niger.
"The UK is closely monitoring events taking place in Niger’s capital," Foreign Office minister Andrew Mitchell said in a statement.
"The UK condemns in the strongest possible terms any attempt to undermine stability and democracy in Niger.
"The UK joins the African Union and Economic Community of West African States in their calls to end the unacceptable events seen today, and to ensure the full and swift restoration of Niger’s democratically elected institutions."
The World Bank said it was closely following the situation in Niger, urging all involved to "maintain peace, stability and security".
Threats to Mr Bazoum's leadership would undermine the West's efforts to stabilise Africa's Sahel region.
US Secretary of State Antony Blinken visited Niger in March, seeking to strengthen ties with a country where extremists have attacked civilians and military personnel, but the overall security situation was not as dire as in neighbouring nations.
Mali and Burkina Faso have had four coups since 2020, and both countries are being overrun by extremists linked to Al Qaida and ISIS.
Mercenaries from the Russian military company also have deployed in those countries.
“Niger and President Bazoum has been the West’s only hope on the Sahel region to contain [extremists] and Russia’s rising influence," said Ulf Laessing, head of the Sahel program at the Konrad Adenauer Foundation.
“Western countries have been showering Niger with aid programmes, from military to development co-operation.
"Even if Bazoum survives this, the reputation of Niger among western policymakers as a stability anchor for the Sahel is damaged.”
Nigerian President Bola Tinubu, who was selected this month as the Ecowas Commission's chairman, said the regional bloc’s leadership would resist any attempt to unseat Niger's government.
“It should be quite clear to all players in the Republic of Niger that the leadership of the Ecowas region and all lovers of democracy around the world will not tolerate any situation that incapacitates the democratically elected government of the country,” Mr Tinubu said in a statement.
“We will do everything within our powers to ensure democracy is firmly planted, nurtured, well rooted and thrives in our region.”
After meeting Mr Tinubu in Abuja, President Patrice Talon of Benin left for Niger as part of Ecowas-led mediation efforts.
“I believe that all means will be used, if necessary, to restore constitutional order in Niger, but the ideal would be for everything to happen in peace and harmony,” Mr Talon said.
The African Union also called on Nigeriens and Africans to “join their voices in unanimous condemnation of this coup attempt, and for the immediate and unconditional return of the felon soldiers to their barracks".
Security analysts said another coup attempt would worsen regional instability.
“The repeated coups in the Sahel signalled the beginning of a new era: an era of militaries being in control, and the end of what it was a hopeful democracy," said Rida Lyammouri, senior fellow at the Policy Centre for the New South, a think tank in Morocco.
"As we are seeing in Burkina Faso and Mali, coups did not really address security issues, which was the justification of these coups.
“Military coups are simply bad and send countries concerned backward rather than forward toward stability and a prosperous future."
The US says it has spent about $500 million since 2012 to help Niger boost its security.
Land-locked Niger has been facing growing acrimony from the new juntas in Mali and Burkina Faso.
It is also a key ally of the EU in the fight against irregular migration from sub-Saharan Africa.