On February 15, 1989, crowds of stunned onlookers watched the last Soviet troops leave Afghanistan over the Friendship Bridge -- defeated after a decade of war.
"The Russians were waving and smiling at the people. It seemed they were tired of fighting," Abdul Qayum, who was a border guard in Hairatan, where the bridge crosses the Amu Darya river into what is now Uzbekistan, told AFP.
With 1.5 million dead on the Afghan side and nearly 15,000 from the Soviets, the Red Army had retreated, defeated by Afghan mujahideen resistance.
The Soviets' December 27, 1979 invasion -- decided in secret by a select caucus of Politburo members -- had been presented in official propaganda as coming to the aid of "a fraternal people" confronted by an Islamic rebellion.
The two countries were linked by a friendship and cooperation treaty signed when Afghanistan became communist a year earlier, after a coup.
Qayum, now aged 60, recalled the confusion as Red Army soldiers rolled into Afghanistan.
"An officer from Uzbekistan told me 'guests were coming' and others on our side of the border were saying it was a Soviet troop parade and they would be returning," he said.
But the army did not turn back.
"There were many, many soldiers. It was impossible to count them. Those crossing into Hairatan immediately marched onwards toward Kabul. They kept crossing for days and nights," he said.
Moscow had thought it would be an easy mission. But it was never able to cut the mountain supply lines of the unrelenting resistance, armed by the Americans, financed by the Saudis and with logistical support from Pakistan.
On April 14, 1988 the Soviet Union committed in accords signed in Geneva to withdrawing its entire contingent of more than 100,000 men by February 15, 1989.
- Joy, pain, bitterness -
The withdrawal unfolded in two phases, each allowing the evacuation of around 50,000 men.
The first lasted from May 15 to August 15, 1988.
The second was meant to start on November 15 but was pushed back as the mujahideen stepped up military pressure. It began, discreetly, in early December.
The conditions were difficult. The columns of vehicles heading to the border from Kabul had to confront the Salang Pass, with its altitudes of 3,600 metres (11,800 feet), in the country's hardest winter for 16 years.
There was also no let up from the resistance fighters, and Soviet soldiers were dying up until the very end.
In the evening of February 15, when it was all over, the highest organs of the Communist authorities hailed the soldiers "who have returned home after having accomplished their patriotic and internationalist duty honestly and with courage."
"At the request of the legitimate government of Afghanistan, you protected its people, women, children, the elderly, towns and villages, you protected the national independence and sovereignty of a friendly country," they said.
But the tone was different in the Moscow press. "To the joy of the return of the soldiers are mixed the pain of losses and bitter reflections," wrote the Communist party's Pravda newspaper.
President Mikhail Gorbachev, who ordered the Soviet retreat, would recall in 2003: "The central committee was inundated with letters demanding an end to the war. They were written by mothers, wives and sisters of the soldiers..."
"Officers were incapable of explaining to their subordinates why they were fighting, what we were doing over there and what we wanted to achieve," said Gorbachev, who said later the invasion had been a serious "political mistake".
- 'Better had they stayed' -
In Kabul "no publicity or special ceremony marked the departure of the last Soviet soldier, who left to the total indifference of officials as well as the local population," wrote an AFP special envoy in a report on February 15, 1989.
In Hairatan, where at 11:30am the last Soviet soldier crossed the Friendship Bridge, local merchant Mohammad Salih said their withdrawal was celebrated.
"But when we saw the civil war and heavy fighting that followed... we thought it would have been better for Afghanistan had they stayed," the 76-year-old told AFP.
Tanks, cannons and anti-air batteries had been deployed at strategic points overlooking the airport for the occasion, the authorities fearing a mujahideen attack.
Three years later, president Mohammed Najibullah resigned, signalling the end of communism in Afghanistan.
His government was replaced by one made up of the various mujahideen factions that had driven out the Soviets. They quickly turned on each other.
Ruined, Afghanistan was more fractured than ever. A new, vicious civil war would soon break out before the Islamist Taliban seized power in 1996.
Red Army tanks cross the Friendship Bridge on the river border between Afghanistan and Soviet Uzbekistan on February 15, 1989, the last day of the Soviet retreat after 10 years of occupation
Soviet soldiers welcomed in Uzbekistan on February 15, 1989 after the Red Army retreat from Afghanistan
Lieutenant General Boris Gromov, commander of the Soviet forces in Afghanistan, addresses his troops in Termez, Uzbekistan, on February 15, 1989 after the Red Army withdrawal is completed