In May 1985, two months after Mikhail Gorbachev became general secretary of the Communist Party of the Soviet Union, he sent one of his cleverest generals to Kabul on an urgent, secret mission. The name of General Zaitsev is unlikely to be well known to today's Nato commanders, but perhaps it should be. Back then he was the Red Army's most senior military planner and logistics expert, and Gorbachev ordered him to provide an honest answer to the question: can the USSR win the war in Afghanistan? He returned to Moscow swiftly with a simple answer: no.
Zaitsev concluded that the only way the war could end on Soviet terms would be to seal Afghanistan's border with Pakistan and thereby prevent the movement of arms and "terrorists" from the mujahedin - the Army of God - into the country. At this point, the Soviets had already committed 100,000 troops; the leadership in the Kremlin was told that about a quarter of a million more would be required to trap the guerrillas inside the country.
Politically, that was impossible. After six years of a war that party bosses in Moscow had been told would be a "surgical operation", over in a few months, more than 7,500 soldiers had died. It was draining resources at a time when the USSR was in an acute financial crisis because of plummeting oil prices. Gorbachev and other Kremlin leaders were inundated by letters from families of troops on duty in Afghanistan, and from the general public, asking why "our boys" were dying in a faraway land about which the Russian people knew little.
In all the debates about the west's role in Afghanistan, politicians, soldiers, diplomats and academics rarely refer to the Soviet experience of a war that lasted nearly a decade. Barack Obama and Gordon Brown are known to be wide readers, but one wonders if their bookshelves hold any of the numerous memoirs by Soviet generals about the USSR's Afghan war.
They should, as today's conflict is eerily reminiscent, right down to battles and skirmishes taking place in the same areas, such as Helmand Province. The Soviets could never pacify the south of the country. Lashkar Gah, the capital of Helmand and a base for Nato troops now, repeatedly changed hands during the war. For long periods during the 1980s, there were intense battles in nearby districts: in Nad Ali, Nawzad and around Marja, a vital centre for Afghan poppy production then, as now.
Listen to a Nato commander talking about the difficulties of fighting the Taliban and you could almost think it was a Soviet soldier from 25 years ago speaking. "Much of the territory stays in the hands of the terrorists. We control the political centres, but we cannot maintain control over
territory we seize . . . Our soldiers have fought incredibly bravely in adverse conditions. But to occupy towns and villages temporarily has little value in such a vast land where the insurgents can just disappear into the hills."
It could easily be the voice of a Nato spokesperson on the Today programme. In fact, these are the words of Marshal Sergei Akhromeyev, commander of the Soviet armed forces, at a meeting of the Soviet Communist Party Politburo on 13 November 1986.
The Soviets searched over many years for an "exit strategy" from Afghanistan, as well as for something that could be described as a "victory". Both were elusive. Critics of current western policy argue that our leaders face similar dilemmas but don't know what the answers are. Yet the Soviet experience is, at the very least, an object lesson in how not to end a war.
Gorbachev used to call Afghanistan "our bleeding wound", but he could not staunch it without losing face or - so he thought - damaging the prestige of the USSR. Newly revealed material from Russia shows how the Soviet leadership dithered and prevaricated fatally. Gorbachev repeatedly made what he said was “a firm decision" to pull out the troops, but then found reason to delay. "How to get out racks one's brains," he complained in the spring of 1986, according to Politburo minutes. "We have been fighting there for six years and if we go on like this it might be another 20."
Withdrawal was a long-drawn-out agony over four years. By the time the last troops left, in February 1989, more than 15,000 Soviet soldiers had died and so had roughly 750,000 Afghans. Gorbachev was haunted by the humiliating image of the last Americans leaving Saigon by helicopter from the roof of the US embassy. "We cannot leave in our underpants . . . or without any," he wrote to one of his aides towards the end of 1988. And like all politicians, he was concerned about how he could spin defeat into something less embarrassing. "We must say that our people have not lost their lives in vain," he told the Politburo.
It was the only war that the Soviet Union lost, and the defeat had far-reaching consequences. The military disaster in Afghanistan was one of the main reasons that first the Soviet empire in Europe, and then the USSR itself, fell. It meant the Russians were no longer prepared to send their troops into battle anywhere. It fuelled the dramatic revolutions in the autumn and winter of 1989 when communist regimes collapsed in a dizzying few weeks. Defeat in the hills around Kabul led directly - and swiftly, within months - to the fall of the Berlin Wall.
Victor Sebestyen's book "Revolution 1989: the Fall of the Soviet Empire" is published by Weidenfeld and Nicolson (£25)