KABUL -- When the Soviet Union invaded Afghanistan in 1979, fortified with tanks, helicopters, and 100,000 troops, empty-handed Afghan guerrilla fighters like Sayed Kassem Muzafari said they had to be innovative.
"We fought with our sheep-shearing knives and made our own grenades from benzine and empty bottles," says Muzafari, who commanded a squad of mujahedin in Parwan Province, to the north of Kabul, and in Bamiyan to the west. It was far from a level playing field, he acknowledges. But "if we hadn't fought, it would have left a heavy burden on our shoulders."
It took more than nine years -- and eventual supplies of foreign-made weapons -- for Afghanistan to rout the Soviet troops. Now, 26 years later, many Afghans see parallels in Ukraine's war against pro-Kremlin separatists in the country's east, and are ready to offer advice.
"Take an example from us -- it's possible to beat a superpower," says Muzafari, who now works with Martyrs' Heirs, an organization supporting the families of slain mujahedin. "Ukraine has a government, an army, an economy. If they don't fight Russia to the end for their country, history will condemn them."
"The enemies of our enemies are our friends," says Afghan historian Habibullah Rafa, speaking simply. "So Ukraine is our friend."
Afghanistan, which last month marked its annual commemoration of the 1989 victory over the Soviets, doesn't appear at first to share much with Ukraine, either culturally or politically. But there are notable similarities.
Both are bordered by historically meddlesome neighbors. Both have had territory seized by Russia -- Crimea and potentially Donbas in the case of Ukraine; in the case of Afghanistan, a large swath of northwestern land claimed in an 1885 battle and absorbed into Turkmenistan. And both have fought Moscow to defend their native cultures and traditions.
"Moscow wanted to take control of Afghanistan," says Mohammad Asif Azimi, a former guerrilla commander in his native Samangan Province, who adds that Kabul's Soviet-backed communist government was grossly out of touch with the country's overwhelmingly Muslim and tribal-based population. "Our religion was in danger. Our culture and language would have fallen."
Analysts in Afghanistan see the current crisis in Ukraine as an unintended consequence of the Afghan-Soviet war, which bankrupted the Kremlin and set the stage for the Soviet collapse and the emergence of 15 independent countries in its wake.
"Moscow still thinks that the 14 other former republics are its satellites," says Vadir Safi, a professor in the law and political science department of Kabul University. "It's especially hard for Moscow to reconcile itself to the independence of Ukraine and Belarus, because they're Slavic states."
Safi, who spent time in Soviet-era Ukraine, says that, even at the time, he noticed a dramatic difference between Russians and Ukrainians. "Ukrainians are like Afghans -- they're very freedom-loving people," says Safi. "When it comes to Ukraine, Moscow isn't going to let up on the pressure."
Moscow, however, may be feeling pressure of its own: a rising body count.
In Afghanistan, Soviet authorities clamped down hard on skyrocketing casualty figures in what was meant to be an easy campaign. By the time the war ended nearly a decade later, the U.S.S.R. had lost an estimated 15,000 soldiers -- and the Soviet public, until then kept largely in the dark, was furious.
The same scenario is now playing out in Ukraine. A newly published report initiated by slain Russian opposition leader Boris Nemtsov asserts that Russia -- despite continued insistence by Russian President Vladimir Putin that his country is not involved in Ukraine -- has lost at least 220 active-duty soldiers in the conflict.
Some Ukrainians are hoping that, as in Afghanistan, Western military aid may also prove a factor.
By the mid-1980s, the United States had joined several foreign governments in providing the mujahedin with heavy weapons, including Stinger surface-to-air missiles, marking a turning point in the war.
The United States has so far provided Ukrainian troops with only nonlethal aid, such as bulletproof vests and night-vision goggles. But it has reportedly mulled supplying self-guided Javelin antitank missiles if the conflict continues.
Even if the Ukraine war comes to an end, some Afghans warn grimly, the aftermath may be even worse. Infighting among the mujahedin in the wake of the Soviet withdrawal created a governing vacuum that was only filled once the extremist Taliban militia seized control of Kabul. That situation led to the 2001 U.S.-led invasion and near-daily factional violence that has taken place ever since.
"You can only beat Putin through unity," says Hekmatullah Hekmat Zadran, a former mujahedin commander based in eastern Ghazni Province, an area of heavy fighting. "My main advice to Ukraine is to be united as a nation. Don't allow a civil war. That's what happens when a nation is fragmented, and it's terrible."
Zadran pauses, then adds another recommendation, one certain to have resonance among many in Kyiv: "Remove former communists and everyone who supports Russia from power."
Perhaps the most vivid lesson Ukrainians can take from postwar Afghanistan is also the most obvious: War changes things in ways that can't be fixed.
Moscow has largely failed to reengage with Kabul in the quarter-century since the Soviet withdrawal, and has watched with chagrin as last year's drawdown of U.S.-led troops has once again created a security gap on its former southern flank.
Historian Rafa suggests that a postwar normalization between states that share a border may be even harder to achieve.
"It takes a long, long time for two countries to build a relationship, but destroying that relationship is easy," he says. "By invading Afghanistan, the Russians ruined relations with the Afghans for a long time to come."