Less than five months after Niger's President Mohamed Bazoum was deposed in a coup, former colonial power France is pulling out the last remaining troops it had deployed to the West African state to fight militant Islamists threatening stability across the region.
Relations with Paris are at rock-bottom - French ambassador Sylvain Itté departed in September at the military junta's insistence - while the European Union (EU) has also been snubbed.
The junta, led by Gen Abdourahmane Tchiani, has unilaterally scrapped the accords under which EU specialists have for many years trained Niger's security forces.
Mr Bazoum regarded France as a crucial military partner. When French troops and other European special forces withdrew from Mali in 2022, he asked them to redeploy into Niger's fragile western border areas plagued by jihadist attacks, where they then operated under Nigérien command.
But after President Emmanuel Macron's vocal condemnation of the 26 July coup and his public support for Mr Bazoum, still detained in his presidential residence, Niger's new military rulers opted for a radical change of policy, demanding that the French pull out.
Most of the 1,500 troops have since left and the remaining 157 will depart by Saturday.
The junta has opted to rely on a new defence alliance with neighbouring Burkina Faso and Mali. They are also both under military rule and resisting demands, including from the West African regional bloc Ecowas, for a rapid restoration of civilian-led democracy.
Yet while France and the EU are cold-shouldered, with Paris blamed for problems and crises of almost any kind and even accused of supporting a 2007 rebellion by Tuareg separatists, the US retains a significant presence, sending a new ambassador to Niamey in August.
And the junta has not demanded the shutdown of the two US military bases in Niger, where more than 600 American troops remain stationed. These are important for Washington as Russian mercenaries from the Wagner group are just over the border in Mali to help the junta there fight jihadists.
There is no doubt that France, and Mr Macron personally, are the object of widespread resentment among young urban populations across West Africa, and not just the states in the semi-arid Sahel strip just south of the Sahara Desert.
Perceived as high-handed and over-assertive, he is resented to a degree that was not true of previous French heads of state, even Nicolas Sarkozy, who had the gall to tell a Senegalese audience that Africa had not sufficiently entered into history.
The priority that Mr Macron has given to West Africa, whether in military efforts to fight jihadist groups, the return of looted cultural treasures or an impressively expanded development budget, has blown back on him.
The soldiers who have seized power in Niger, Burkina Faso and Mali over the past three years have all opportunistically played the anti-French card to boost their popularity.
As their countries feel the pressure of increased economic isolation, and reduced development and security support, the former colonial power is a useful scapegoat.
Paris, and indeed Brussels, have also paid a price for their strong support for Ecowas.
The bloc's 2001 democracy and good governance protocol is the foundation for its uncompromising stance towards the coup leaders and its efforts to pressure them into taking steps towards the re-establishment of elected government, with Niger in particular targeted by a trade blockade and the threat of military intervention.
Yet Ecowas itself is widely unpopular, often portrayed as a presidents' club that has turned a blind eye to election rigging and constitutional manipulations as heads of state seek to extend their stays in power.
In this polarised context, where Gen Tchiani and his Malian and Burkinabè counterparts, Col Assimi Goïta and Capt Ibrahim Traoré, are tapping into powerful nationalistic resentment, the US has played a softer-toned public game.
It waited many weeks before finally acknowledging the overthrow of Niger's elected government, which automatically, under American law, triggered the suspension of most development aid.
With a generally favourable or neutral image in West Africa, where it has no colonial history and the Cold War left no painful conflict legacy, Washington has been able to sustain diplomatic engagement with the military regimes in a way that Paris could not have done without a humiliating disavowal of its core policies and track record.
Coup leaders have been willing to meet high-ranking US State Department officials and hear them utter uncomfortable public messages.
In Niger's capital Niamey last week, Assistant Secretary of State for African Affairs Molly Phee called on the junta to open talks with Ecowas after the bloc offered a relaxation of sanctions in return for clear progress on a return to constitutional rule - and she offered a powerful incentive for steps down this path.
After the coup the US suspended its military co-operation with Niger's security forces, but Ms Phee said Washington intended to resume collaboration and development support "in phases", reciprocating actions taken by the junta towards the restoration of democracy.
Besides long-running programmes of training with Nigérien forces, the US has drone bases in Niamey and in Agadez on the edge of the Sahara, that it regards as crucial for monitoring the activity of jihadist groups across the region and Wagner mercenaries in Mali and Libya.
So Gen Tchiani's regime feels in a strong bargaining position. Setting an assertive tone, Prime Minister Mahaman Lamine Zeine said on Wednesday: "If the Americans want to stay here with their forces they should tell us what they want to do."
Mr Zeine was not shy to hint that Niger has other suitors and alternative friends if the US does not play ball. Russia's Deputy Defence Minister Gen Yunus-Bek Evkurov visited Niamey earlier this month.
Moreover, the Sahel could well be a priority testing ground for the reintegration of Wagner forces into a more conventional structure under tighter control by the official Russian defence establishment. That more orthodox model might have some appeal for Niger, which has strong official military traditions.
Moscow is also trying to broaden its "offer" to the Sahelian states beyond the security sphere, even though it is not equipped to match the development donor clout of the EU, the US, Germany or France.
Last month it sent a team of doctors to help Burkina Faso deal with outbreaks of dengue fever and chikungunya.
So Washington knows it is operating in a competitive diplomatic environment.
It may have taken a gentler public diplomatic line than Paris, but will not be spared awkward dilemmas and hard choices in dealing with military regimes that currently don't feel they have to look to the West or even, in some cases, the United Nations.
However, Niger's military rulers also face awkward dilemmas. While overtures from Russia and declarations of solidarity from Burkina Faso and Mali provide a degree of political comfort, the humanitarian and security realities are grim.
Mr Bazoum's drive to reassert security control over fragile border areas, creating improved conditions for the return home of displaced populations had begun to bear fruit - with levels of violence continuously decreasing since 2021, according to the violence monitoring group Acled.
Improved harvests and strong donor support were also reducing the risk of food crisis for rural communities.
But since the coup, a combination of Ecowas trade sanctions and the suspension of much development aid, has sharply worsened living conditions for many households and jeopardised long-term development programmes.
And after many army units were redeployed to Niamey to guard against a potential Ecowas military intervention, there was a marked upsurge in jihadist attacks and inter-communal violence elsewhere in the country.
For example, in late October and early November, some 4,750 villagers fled to the town of Bankilaré, in the west, after armed groups forced them to abandon their homes.
In theory, Niger's new alliance with Burkina Faso and Mali might improve cross-border military co-operation to tackle jihadists, criminals and community violence.
But the forces no longer benefit from the high-tech intelligence and air support capacity that France and the US were able to provide.