Ghosts of Afghanistan: The Haunted Battleground. By Jonathan Steele. Counterpoint; 437 pages; $26. Portobello; £25. Buy from Amazon.com, Amazon.co.uk

ON TAKING office in 2009, President Barack Obama found a longstanding request from the army on his desk, asking for more troops for the war in Afghanistan. He soon acceded, though not in full. According to Bob Woodward's book, “Obama's Wars”, which came out in 2010, the late Richard Holbrooke, Mr Obama's envoy to Afghanistan and Pakistan, reminded his boss that Lyndon Johnson had faced similar demands during the Vietnam war. “Ghosts”, whispered Mr Obama. They haunt him still, as he seeks to bring most American troops home before 2015, without leaving Afghanistan prey to a new extremist Taliban regime or an intensification of its three-decade-long civil war.

“Ghosts of Afghanistan” is a good title for this fine modern history by Jonathan Steele, a British journalist. This is not just because of the many people who have died in its wars, but because “the spectres of past mistakes” still complicate decision-making by the NATO-led, American-dominated International Security Assistance Force (ISAF).

These include both the quagmire in Vietnam and the Soviet Union's disastrous nine-year occupation of Afghanistan in the 1980s, which was cheered by Western cold warriors as “the Soviet Union's Vietnam”. An experienced writer and commentator for the Guardian, Mr Steele has visited Afghanistan in every phase of the civil war and is well placed to compare the end of the Soviet era and the present “transition”, the favoured common euphemism for foreign withdrawal.

He demolishes some Western myths about Afghanistan that betray short memories and government spin. The Soviet years, for example, tend to be portrayed as a period of bitter repression under a puppet regime, which was defeated by a popular, Islamist uprising, backed by America and Pakistan, and which crumbled as soon as the Soviet Union withdrew its occupation forces in 1989.

There is another way of looking at the same history. At no stage did the Soviet Union have as many troops in Afghanistan as America and ISAF do now. It was never defeated. It withdrew because Mikhail Gorbachev realised the Soviets could never win. The regime they left behind was quite resilient. Only as the Soviet Union began to unravel in 1991 and withdraw its aid did the regime collapse shortly after. The mujahideen boast of having brought down the Soviet Union. The reverse is just as true: it was the collapse of the Soviet Union that brought the mujahideen to power.

There are some uncanny echoes between the two interventions. The Soviets and the Americans both allocated 15 times as much to military spending in the country as to civilian spending. Soviet resentment at the ingratitude of the client regime is matched in America. This month ISAF had to sack an American general for voicing it. Neither the West nor the Soviet Union is predominantly Muslim, enabling their enemies to decry the “infidel” regimes they back. Both wars became very unpopular at home. ISAF, like the Soviet army, has established solid-looking structures in the north, which is largely inhabited by smaller ethnic groups, such as Tajiks, Uzbeks and Hazaras. But it still faces a serious insurgency in the Pushtun-dominated south and east, fuelled from Pakistan.

With the war in stalemate now, as it was 20 years ago, Mr Steele argues for peace talks with the Taliban and the regional powers. That, of course, is how wars end. But it is hard when the enemy, known in convenient shorthand as “the Taliban”, is fragmented and ISAF is trying to kill or co-opt as many of its fighters as possible. Moreover, America has committed itself to a timetable for withdrawal—an invitation to its enemies to play a long game.

In one respect the Soviet precedent is not encouraging. That withdrawal was preceded by years of ultimately fruitless diplomacy. But the foreign presence is not the only reason Afghans fight. So the lesson some ISAF strategists draw from the Soviet experience is less to do with the necessity for peace talks than about the durability of the post-occupation Afghan government until its plug was pulled from a socket in Moscow. If the West can commit enough in military and civilian assistance, the present government should muddle through, at least in the cities.

That is not a very encouraging outcome, measured against the high hopes after the swift toppling of the Taliban in 2001. But Mr Steele gives almost the last word in his book to an even gloomier scenario, spelled out by Francesc Vendrell, a wise diplomat formerly with the UN and the EU: “Having failed dismally to make the Afghan people our allies, we will inevitably abandon them to a combination of Taliban in the south and the warlords in the north, and (having somehow redefined success) we will go home convinced that it is the Afghan people who have failed us.” Mr Steele and Mr Vendrell are not the only ones to be haunted by the ghosts of Afghanistan's future.