One of the enduring tragedies of America’s war in Afghanistan is that our ambition to improve the country has been so outgunned by our impatience at the slow progress in Kabul. There’s no denying that the American public is exhausted with news from Afghanistan, and politicians have largely responded by either ignoring the topic or urging more cuts to funding for stabilization efforts there. Unfortunately, the lessons of recent history in Afghanistan (1989-1992) and Iraq (2011-2014) suggest that without the right kind of support, billions of dollars invested in training an army and setting up a government during an insurgency can quickly go up in smoke. It would be a horrible tragedy if that were to repeat itself in Afghanistan after our full withdrawal in 2016, and a brief analysis of two relevant historical analogies can help us to understand the dangers of prematurely disengaging from Afghanistan.

The Soviet military withdrew from Afghanistan in 1989, and to the surprise of many, the government left behind in Kabul in the hands of Dr. Mohammed Najibullah did not fall immediately. The mujahedeen were quickly able to seize the city of Khost, but they proved too uncoordinated and incompetent to decisively engage Kabul. As Barnett Rubin explains in his book “The Fragmentation of Afghanistan,” what finally destroyed Najibullah’s government was the collapse of economic and military aid from the Soviets. The centrifugal force of competing factional interests in Kabul had been held in check as long as funding, food, and fuel were plentiful for the military and government supporters. However, when the Soviet Union (and thus Soviet aid) dissolved in late 1991, everything fell apart.

The Soviets left the Afghan government in 1989 in charge of an economy in total shambles with no clear internal source of revenue to pay for the large military necessary to keep the mujahedeen from overrunning Kabul. The Afghan state of the early 1990s could only last as long as someone was willing to foot the bill. Unfortunately, as of 2014, the World Bank projected that the current Afghan government would need approximately $7 billion annually in foreign aid just to sustain day-to-day operations, maintain infrastructure, and pay the salaries of the Afghan National Security Forces. Of course, even if foreign donors are willing to continue to pay this hefty bill, there has to be a functioning security force in place for this effort to be meaningful, and high casualty rates and desertion have left the Afghan military reeling.

2014 was a brutal year for the Afghan National Security Forces. In November, the then commander of the NATO’s joint command in Afghanistan, U.S. Army Lt. Gen. Joseph Anderson, described Afghan security force’s casualty rate as unsustainable. This has contributed to the problem of attrition in the Afghan military at a time when the number of NATO troops has fallen to approximately 12,000. Fears over the potential impact of public knowledge of this attrition may have led the Department of Defense to classify certain data in late 2014, a decision which it recently retracted under pressure from the Special Inspector General for Afghanistan Reconstruction and journalists. When the Afghan military was faced with similar rates of attrition in 1991, the results were catastrophic. We can only hope that we possess the political will to enact a plan to prevent attrition from pulling the Afghan military apart for the second time in 25 years.

The recent experience of the U.S. withdrawal from Iraq in 2011 after years of training and assistance for the Iraqi security forces also provides a cautionary tale for anyone unconcerned about the now-shaky status of security in Afghanistan. Although many may not remember it now, by 2009, U.S. forces had withdrawn from cities in Iraq at a time when 130,000 American soldiers still remained in country. That means that the Iraqi security forces had nearly two years of time managing an increasing share of the security operations in Iraq while still receiving significant U.S. training and advice. Of course, this is in addition to the five years of training that Iraqis had already received from coalition forces. Even so, the forces crumbled quickly when the Islamic State of Iraq and Syria invaded in 2014. After nearly $25 billion and seven years of training from U.S. forces, how did this happen? The answer is relatively simple: politics.

Nouri al-Maliki, the prime minister of Iraq from 2006-2014, spent years alienating the Sunni population, and making them relatively receptive to ISIS’ advance in 2014. More pointedly, according to retired Col. Peter Mansoor, Maliki purged the Iraqi military leadership of officers who he viewed as potentially disloyal. My conversations with an Army officer well-versed in these events indicated that the only portion of the Iraqi troops that was operationally effective after this purge was the Iraqi Special Operations Forces. But, during ISIS’ advance in 2014, Iraqi special operators sustained so many casualties that they were rendered combat ineffective, leaving no one to defend the country as remaining Iraqi officers fled their posts.

The lesson of the U.S. withdrawal from Iraq in 2011 is complex, but one point seems clear and salient to our current situation in Afghanistan: If we withdraw too much support, then we no longer have the ability to influence disastrously counterproductive government policies like Maliki’s purge of the military and his long alienation of Sunni Muslims.

Building a strong, professional security force in a country wracked by insurgency is a horrendously difficult, and expensive task. If recent history in Iraq and Afghanistan are any guide, we have probably grossly underestimated how long it takes to build a security force that won’t collapse quickly after withdrawal. As analyst Philipp Munch has pointed out, many of the Afghan security force’s problems are not actually technical in nature, and it may take many years for cultural improvements involving nepotism and wage theft to take place as younger officers grow into a new system and take command. In other words, the U.S. may need to sustain a significant training presence and provide major economic support to Afghanistan long past president President Obama’s 2016 deadline for withdrawal of the remaining troops.

Obama has stated that “we have to recognize Afghanistan will not be a perfect place, and it is not America’s responsibility to make it one.” This is surely true, however, every indication so far is that if attrition is not dramatically reduced within the Afghan military, disaster is inevitable. I’m not an advocate for a permanent U.S. military training and advisory mission in Kabul, but given the current sorry state of affairs, it is difficult to imagine how the Afghan security forces could be totally prepared to stand on their own by 2016.

It may be unpalatable to keep spending money in a country where so much money has been wasted, but if the other option is to step back and watch the economy and military collapse while the Taliban and al-Qaida wait patiently in the nearby mountains, then the choice seems clear. We have the tiger by the tail in Afghanistan, and we need to be sure that we know what will happen before we let it go.