Those who claim that we can disengage from Afghanistan now that the "emir" of al Qaeda is dead seem to assume the whole organization will disappear with him. It might, but it might not. Other terrorist groups such as Hamas and Hezbollah have survived the loss of their leaders.

Opponents of the war effort also argue that the Navy SEAL raid should be a model for the kind of counterterrorist approach we should adopt more generally, relying on pinpoint strikes rather than dispatching 100,000 ground troops to carry out a grueling counterinsurgency campaign.

President Obama has repeatedly provided superficial support for this view by claiming that our "core goal" in Afghanistan is limited to "disrupting, dismantling and defeating al Qaeda." No doubt he put the emphasize on al Qaeda because it is the terrorist group that most Americans worry about the most. But since 2001 it has never had more than a few dozen fighters at a time inside Afghanistan.

Of greater immediate concern are al Qaeda's allies: the Quetta Shura Taliban, the Haqqani network and Hezb-e-Islami Gulbuddin (HiG), which among them deploy thousands of hardened terrorists. These groups, in turn, are part of a larger conglomeration of extremists based in Pakistan including the Tehrik-i-Taliban Pakistan (the Pakistani Taliban), Lashkar-e-Taiba and Jaish-e-Mohammed.

All of these organizations share an eagerness to slaughter civilians and a desire to create a totalitarian regime modeled on Taliban-era Afghanistan. All are rabidly hostile to Westerners, Jews, Hindus, Shiites and anyone else who does not share their hard-core Salafist beliefs.

The major difference among them, at least so far, has been one of geographic focus. The Taliban, the Haqqani network and HiG want to seize power in Afghanistan. The Pakistani Taliban aspires to rule in Islamabad. Lashkar-e-Taiba and Jaish-e-Mohammed are primarily focused on wresting Kashmir away from India, although there have been reports of the former's network expanding into Bangladesh, Nepal and Sri Lanka. Only al Qaeda has a global focus—so far.

But whatever their tactical differences, these groups have established a mutually supportive relationship with the help of Pakistan's Inter-Services Intelligence. Lashkar-e-Taiba's founder, Hafiz Muhammed Saeed, said this week that "Osama bin Laden was a great person." Mullah Omar, the leader of the Taliban, was even more closely aligned with bin Laden. If the Taliban had repudiated al Qaeda after 9/11, they could have avoided a U.S. invasion. But they chose to go down with their Arab friends, and there has been no sign since of any serious fissure between them.

It is immaterial whether or not the Taliban, the Haqqani network, Lashkar-e-Taiba and the others are currently targeting the American homeland. We cannot allow them to create a fundamentalist caliphate stretching from Kabul to Kashmir and beyond. Their takeover of Afghanistan—a first step toward this grandiose goal—would galvanize jihadists and could reverse the loss of momentum they have suffered because of the Arab Spring and bin Laden's death. It would also provide greater impetus to topple the nuclear-armed Pakistan next door.

Islamists have already made dangerous inroads in Pakistan, as seen from the fact that Osama bin Laden was able to live in a military garrison town just 35 miles north of Islamabad. Having bases in Afghanistan is our best bet for projecting power into Pakistan—as the SEALs showed. But there is no way the government of Afghanistan would allow us to keep bases there if we stopped supporting it. If an American exit were imminent, Hamid Karzai and other politicians would rush to cut a deal with the Taliban to save their own necks.

That would mean that we would be reduced to the pre-9/11 status quo when we used ineffectual cruise-missile strikes to try to kill top terrorists. Successful Special Operations require a significant intelligence-gathering apparatus on the ground and close proximity to launch raids with little warning time. Our presence in Afghanistan gives us those advantages, without which we could not have carried off the bin Laden raid.

To prevent the fall of Afghanistan, we must do more than launch a few raids or air strikes. If not, the terrorists will be able to regenerate themselves. That's what the Taliban, the Haqqanis and others did between 2001 and 2009—the years when we never had more than 30,000 troops on the ground. Only last fall did we finally surge to 100,000 American troops, along with 40,000 allied ones. For the first time, that gave us the capability to "clear, hold and build." During my recent travels in Kandahar and Helmand, I saw coalition troops securing areas that only a few months before were Taliban strongholds.

But the gains achieved so far are tenuous and reversible. The Taliban are back on the offensive. It is vital to stick to the strategy NATO announced last fall of not putting Afghans in the lead until 2014. Moving too quickly to turn over control to unready forces can be disastrous—as shown by last month's breakout of more than 400 Taliban fighters from Kandahar's main prison.

If we give more time to Gen. David Petraeus and his successor, Gen. John Allen, they can strengthen Afghanistan enough—mainly by building up the indigenous security forces—to prevent a Taliban takeover or a ruinous civil war even after U.S. forces finally start drawing down. That, in turn, can help us to stabilize Pakistan: an outcome worth fighting for.

Mr. Boot, a senior fellow at the Council on Foreign Relations, is writing a history of guerrilla warfare. This article first appeared in the Wall Street Journal and has been republished with the author's permission.