Writing in his autobiography “The Baburnama”, the first of the great Moghuls Zahiruddin Babur revealed that he captured "Kabul and Ghazni without bloodshed" in the early 16th century.

In a letter to his mother in Farghana, in today's Uzbekistan, he described people of the Kabul region as always fighting among themselves, but uniting against outsiders. Heeding his mother's advice to never live among such people, Babur moved on to India and founded the Moghul Empire.

Three hundred years later, in 1839, the British wanted a buffer against Russia and so they invaded Afghanistan, deposed King Dost Mohammad and installed former King Shah Shuja, who had been living in exile in India for 30 years.

Shuja was seen as a British puppet. A local chieftain, reportedly, asked the British: "You have brought an army into the country. But how do you propose to take it out again?" Of the 58,000 men, who went in to take Afghanistan, only 4,500 left Kabul in the winter of 1842-43.

The Economist describes that campaign as a "story that hangs heavy with imperial overconfidence, political incompetence and wilful bureaucratic misjudgement."

In 1979, suspecting that the communist Afghan leader Hafeezulah Amin was cosying up to the Americans, Soviet troops moved in and swiftly occupied Kabul, killing Amin and replacing him with Babrak Karmal.

By the time the last Soviet soldier returned home on February 16, 1989, "the war.......had become a domestic burden and an international embarrassment for Moscow," the New York Times observed.

That war scarred a whole generation of young Soviets and triggered the collapse of the Soviet Union. The war fractured Afghan and Pakistani societies, and the two countries continue to bear its consequences. The story of Soviet misadventure is little different from the British one, more than a century earlier.

In 2001, the Americans, just like previous invaders, moved in swiftly and captured Kabul. After ejecting the Taliban, they installed Hamid Karzai, who had previously been in the service of the American energy company Unocal, with an interest in setting up a Turkmenistan-Afghanistan-Pakistan-India gas pipeline.

Next year, after numerous casualties and billions of dollars in cost, the US combat mission is ending like the previous two: due to the unsustainable cost of occupation and waning political support at home for a war that is widely considered unjust.

As coalition forces begin withdrawing from Afghanistan, we see the replication of the Soviet story, as the NY Times noted again: "Not a single battlefield engagement was lost to guerrillas, and no outpost ever fell to insurgents."

Today, there is serious doubt about the ability of the political and security apparatus, which the US is leaving behind to provide for sustainable peace in Afghanistan. The 200,000-strong Afghan National Army and the 150,000 strong police force are heavily dependent on the US for support services.

The army's morale is low due to high combat deaths and 30 percent desertions. The force needs to find about 60,000 new able-bodied men every year. As foreign forces withdraw and the army assumes more responsibility, these figures are certain to increase.

With no ideological commitment, most of the army's personnel fear they will be left defending a regime bound to crumble without foreign troops. In such a situation everyone expects a repeat of the civil war that followed the withdrawal of Soviet troops.

The US, on the other hand, while winding down the combat mission, wants to leave a few thousand troops behind, ostensibly for training purposes but with rapid deployment capabilities.

The US-Afghan Strategic Partnership Agreement, signed by the two countries last year, holds in abeyance the question of immunity for the residual US forces. Without immunity, the US is unlikely to leave troops on the ground. And their presence means that resistance will continue.

Mr Karzai's dilemma is that he needs the American troops, but the Taliban bottom line for peace is the total exit of foreign forces. A US garrison in Afghanistan would also be disconcerting for China, Russia and Iran.

The situation is further complicated by the timing of the Afghan presidential elections in 2014 - from which Karzai is barred for having already served two terms. The election coincides with the withdrawal of US combatants.

Hopes for progress in peace talks with the Taliban have yet to come to fruition.  Karzai, fearing being sidelined as the Americans deal with the Taliban, insists that the Taliban must talk to the country's High Peace Council, the government body leading such negotiations. But the Taliban refuse to talk to the "powerless" Karzai government, which they claim was "installed by others."

For now, the emphasis is on peaceful troop withdrawal. But a transition that does not adequately address the flaws in the power-sharing plan is bound to be rocky, leading to a meltdown of the state structures the Americans will leave behind.

In an internal collapse, neighbouring states will be compelled to fund their proxies, resulting in civil war - a repeat of the 1990s.

Like previous invading powers, the US made the mistake of attempting to create a society in Afghanistan in its own image without realising its history, tribalism and culture. The next adventurer tempted to enter Afghanistan would do well to heed the advice of Babur's mother.

The writer is a member of Pakistan's Foreign Service from 1973 to 2008, is an adjunct professor at the Lee Kuan Yew School of Public Policy, National University of Singapore, and a visiting senior research fellow at the Institute of Southeast Asian Studies, Singapore. This article has been reprinted from The National.