Making a difference: The view from a French helicopter patrolling in northern Mali last week. Though withdrawing, France will leave some troops in the region to continue the battle against Islamists if needed.AP

The fighting season in Mali ends in three weeks and France, which has shouldered the brunt of the counter-terrorism war there, is looking for an exit strategy. So now what?

Some 4,000 crack French troops have been fighting in Mali since January, systematically dismantling one of the world’s most formidable jihadist bases since the United States invaded Afghanistan in 2001 to evict al Qaeda.

But temperatures in northern Mali are about to climb to three digits, so until late fall even the most inured desert foxes will rather seek shade than fight.

Traditionally, such nature-forced off-seasons have given warriors in (literal) hot zones time to take stock and contemplate their next move. In this case, France is ready to exit its former colony as early as feasible.

But then what? Paris wants a UN peacekeeping force to take over. France’s foreign minister, Laurent Fabius, said Thursday that he hopes to get the UN Security Council to mandate a Mali force by April, so it could deploy in July.

But here’s the rub: As impressive as the French military campaign has been, even its most enthusiastic admirers don’t pretend that the threat — that Mali would turn into Afghanistan II — is gone. Desert warriors are very good at retreating in the face of superior foreign forces, only to return and regain territory once those forces leave.

Al Qaeda and its African affiliates are especially adept at moving across borders. As the US ambassador in Nigeria, Terence McCulley, told reporters Thursday, the United States has monitored jihadist groups for yearsas they effortlessly move between Nigeria, Mali and other nearby countries.

So yes, the French have chased Al Qaeda in the Islamic Maghreb and its affiliates from northern Mali. But if Paris’ troops are gone when the fighting resumes in late September, the jihadists may well return, turningMali into al Qaeda’s main base of global operations after all.

And forget the United Nations: While ending the terrorist threat is clearly the top goal of the French campaign in Mali, it won’t even be mentioned in any UN force’s operational manual. By definition, a peacekeeping force is there to keep a fragile peace, not take sides — not even against jihadists.

As Canadian Prime Minister Stephen Harper said this week, Ottawa may contribute troops or assets to the proposed UN force, but “We are not looking to have a combat, military mission” in Mali.

So once France is gone, who’ll fight the terrorists in Mali?

The mood in Paris is against the kind of hasty retreat that allows politicians to boast “we brought the boys back home,” but then erases all the gains made through a successful military campaign.

On the other hand, having ruled Mali as a colonialist power, France worries that staying too long now will risk seeming a foreign occupier.

UN diplomats tell me that the emerging plan in Paris is to phase out the troops as UN peacekeepers replace them — and then deploy someof them in traditionally French-friendly neighboring countries, such as Chad and Senegal.

This residual French force would then intervene as needed in the fighting in Mali to assure that the jihadists don’t return to the north. (US help, drones and such, would be much appreciated.)

What of non-military solutions? There’s talk of such for Mali, including an early July election. But Southern Malians are for now intent on exacting revenge on their Tuareg and Islamist nemeses, so political “reconciliation,” a precondition for successful UN peacekeeping, is far off.

The French, in other words, face the same dilemma in Mali that America has faced in Iraq, Afghanistan and elsewhere: how to responsibly exit wars against terrorists.

In the Obama era, White House politicos have made these decisions, with political considerations and talk of America’s “war-fatigue” trumping all strategic issues. (“The Dispensable Nation,” a new book by former State Department Afghan hand Vali Nasr, is a brutal account of this process.)

The French, for now, seem more tuned to the pitfalls and dismal aftermaths of hasty retreats. In Mali (who’da thunk it?), France may yet show us a better way into, and out of, battle.