Thousands of people protested in Niger last month to demand the immediate departure of US soldiers
The US and Niger have agreed that American troops will leave the country "no later" than 15 September, they announced in a joint statement on Sunday.
They said the two countries had "reached a disengagement agreement to effect the withdrawal of U.S. forces, which has already begun".
The US has relied on Niger as its primary base for monitoring regional jihadist activity.
The military junta which seized power last year has already ordered French troops to leave, while moving closer to Russia.
The statement commended the "joint sacrifices of Nigerien and U.S. forces in the fight against terrorism", adding that the withdrawal would not affect the continuation of US-Niger relations.
"The United States and Niger are committed to ongoing diplomatic dialogue to define the future of their bilateral relations," it read.
The deal was reached after marathon talks between the two countries in Niamey.
In March, Niger announced the end of its military agreement with the US. Military spokesperson Col Amadou Abdramane accused the US of raising objections about the allies that Niger had chosen.
Col Abdramane condemned the US for its "condescending attitude" and "threat of reprisals".
Tensions spiked between the US and Niger after elected president, Mohamed Bazoum, was overthrown last year.
Niger is in Africa's Sahel region, considered the new global epicentre of the Islamic State group.
American forces have used two military bases in Niger to monitor Islamist militant groups in the Sahel.
The US built a $100m (£80m) military base there six years ago in the central city of Agadez, 750km (460 miles) north-east of Niamey.
It has played a key role in the US strategy to combat jihadists in West Africa.
The US has more than 1,000 troops stationed at the base.
It is the second Western power to withdraw from Niger.
Last year, Niger expelled former colonial power France's troops, who had also been deployed to fight jihadists.
As Niger has distanced itself from the West, it has drawn closer to Russia.
Last month, Russian military instructors arrived in Niger as part of a new agreement with its military leaders.
Niger has also broken away itself from local democracies and sought stronger regional alliances with fellow junta-led nations Burkina Faso and Mali.
The trio have quit Ecowas – the West African regional body which opposed their military takeovers.
They have also quit the French-backed G5 Sahel force, saying it was ineffectual and undermined African sovereignty, and launched their own defence pact called the Alliance of Sahel States.
Why West Africa's united front is in tatters
'France takes us for idiots' – Inside coup-hit Niger
Why young Africans are celebrating military takeovers
Go to BBCAfrica.com, external for more news from the African continent.
Follow us on Twitter @BBCAfrica, external, on Facebook at BBC Africa, external or on Instagram at bbcafrica, external
Africa Daily
Focus on Africa
Sunak announces UK general election for 4 July
Ex-Post Office boss cries as she admits incorrect evidence
One person dies in North Yorkshire mudslide
Armies of young insurgents are changing the course of a forgotten war
Who is Paula Vennells? Ex-Post Office boss in Horizon IT inquiry
Watch: Ex-Post Office boss cries while giving evidence. Video
Is climate change making turbulence worse?
Children detained under little-known orders speak out after turning 18
Diddy assault video cements fall of hip-hop icon
'Unlucky in love' flamingo lays first egg aged 70
Election poll tracker: How do the parties compare?
Shaznay Lewis: 'I lacked the self-esteem to go solo'
Do air fresheners actually get rid of bad smells?
Greg Foot investigates how these products tackle odours in our homes and if they're worth purchasing
Powerful, premium US drama
The true story of the dealers, doctors and the billion dollar drug that fuelled America's deadly opioid addiction
Nat and Jo hear from listeners about their fave comfort telly
From Only Fools and Horses to a good old period drama, Nat and Jo discover the nation's favourite shows
Two superpowers on the brink
The hidden, true stories of Cold War spies and traitors embroiled in deadly games of cat and mouse
When a criminal conflict turns personal
Inside the UK's most historic homes
From the Paris suburbs to global stardom
A journey of self-discovery across Italy
© 2024 BBC. The BBC is not responsible for the content of external sites. Read about our approach to external linking.

More Stories
Empowering Parents in Rwanda Through Digital Literacy Training
Advancing the Safer Internet Initiative for Everyone
Youth in Action: Contributing to a More Connected and Inclusive Digital Future