For nine years, France was Mali's staunchest ally in its fight against jihadists who have claimed thousands of lives and driven hundreds of thousands from their homes.
Today, French forces are pulling out after a breakdown with the country's military junta, which this week renounced Mali's core military agreements with France.
What has happened?
France began its anti-jihadist operations in the Sahel in 2013, helping Mali, its former colony, to snuff out a revolt in the north.
But the jihadists regrouped to attack the volatile centre of the country, initiating a full-throated insurgency that elected president Ibrahim Bubacar Keita was unable to brake.
In August 2020, protests against Keita culminated in a coup by disgruntled colonels -- a move followed by a second military takeover in May 2021.
From then on, relations with France went steadily downhill, propelled by the junta's resistance to setting an early date to restore civilian rule and by Bamako's charges that France was inciting the region to take a hard line against it.
The bustup accelerated in 2021 as the junta wove closer ties with Moscow, bringing in "military instructors" that France and its allies condemned as mercenaries hired from the pro-Kremlin Wagner group.
In January this year, the French ambassador to Bamako was expelled and the following month, France announced the pullout of its troops from Mali, and those of the French-led Takuba force.
Mali ditches accords
In the latest twist, the Malian government on Monday formally renounced three agreements that provide the legal foundation for French and French-led military activities in Mali.
- The Status of Forces Agreement, a 2013 accord that set down the terms of reference for France's Serval (later Barkhane) forces stationed in Mali. The agreement determines, among other things, the freedom of movement of French forces and who has jurisdiction in the event of problems.
- A bilateral defence treaty, signed in 2014
- A 2020 protocol to the 2013 Status of Forces Agreement that applies to Takuba -- a coalition of European special forces that France hoped would take over some of the burden-sharing in Mali.
Why did Mali quit?
Mali accuses France of acting unilaterally and of being deaf to its requests to amend the accords -- the result of which, it says, is "blatant violation" of its national sovereignty.
It says, for example, that French aircraft have violated Malian airspace around 50 times in previous weeks, ignoring a huge air exclusion zone that it has declared. France denies this.
There has also been another episode that has inflamed the situation.
Last month, the French army shared a drone video that it said showed Russian mercenaries burying bodies near a base at Gossi, a day after the French military handed the facility back to Mali.
The point of the bodies, France said, was to falsely accuse its departing troops of war crimes.
Mali reacted furiously, accusing the French army of "spying" and "subversion."
What are the consequences?
France has 2,400 troops and several bases in Mali, and safely unwinding this operation is a dangerous, months-long task.
On Tuesday, the political temperature rose further when Foreign Minister Abdoulaye Diop said there was no longer a "legal basis for France to operate on Malian soil."
He said France could continue to work on the pullout, but "anything which takes place on the territory of a sovereign state should be discussed and agreed with the state which is in place."
Niagale Bagayoko, head of the African Security Sector Network (ASSN) think tank, is among those who fear the danger from heightened suspicion or misunderstandings -- the risk of a "blunder" that puts French and Malian forces in confrontation.
A further unknown is the impact for the United Nations' peacekeeping force in Mali, which with 14,000 troops and police is one of the biggest UN operations in the world.
The UN mandate for MINUSMA authorises French forces to support the mission "when (it is) under imminent and serious threat."
If that support has to end because the agreements governing French forces are no long valid, "that will obviously lead to consequences," MINUSMA spokesman Olivier Salgado told AFP, adding however that the mission would be able to adapt.