President Warren Harding once said, “I have no trouble with my enemies,” but noted that his friends “keep me walking the floor nights.” That maxim should have applied to U.S. foreign policy since 9/11 and even before that.

It is sometimes puzzling why the U.S. government fears faraway countries that currently pose no direct threat to the United States—for example, Iran, North Korea, Saddam’s Iraq—while downplaying actual threats emanating from “friendly” nations.

We all know the story of how most of the 9/11 hijackers were Saudis, how the Saudi government has funded radical Islamic schools all over the Muslim world, and how private Saudi money has made its way to al Qaeda and the Taliban in Afghanistan and Pakistan.

But the U.S. press recently reported that the ISI, the Pakistani intelligence service, supposedly a U.S. ally since the war against the Soviets in the 1980s, was supporting militant Islamic fighters against U.S. and NATO forces in Afghanistan. This information should not be new or surprising. During the Soviet war, the CIA funneled billions of dollars through the ISI to militant Islamic fighters. The ISI chose which groups to finance with CIA money. Serving its own interests, the ISI funded the most radical Islamic fighters, including Osama bin Laden, when more moderate groups were better anti-Soviet fighters.

Since 9/11, the Pakistani government has fleeced the U.S. government for billions in aid to fight such militants, while at the same time its intelligence arm is funding the same people, providing their arms, and even planning their attacks. Thus, because money is fungible, the U.S. government is essentially using U.S. taxpayer dollars to fund its enemies on the battlefield. Of course, having enemies to fight—the Taliban and other militant groups—garners the U.S. Department of Defense more cash from Congress and the American people. Everyone seems to be happy with this bizarre arrangement, except maybe U.S. taxpayers and the families of U.S. soldiers and Afghans killed.

Barack Obama’s stated policy to deal with this mess is somewhat better than George W. Bush’s. Being more pragmatic, Obama’s goal is to stabilize Afghanistan enough so that it cannot be used as a base for al Qaeda to launch attacks against the United States, its interests, or its allies or for al Qaeda to undermine or topple U.S.-backed democratically elected governments. As in Iraq, he has also promised to eventually withdraw from Afghanistan. Obama’s stated policy is at least better than George W. Bush’s open-ended, ill-defined nation-building project.

However, in the shorter term, Obama appears to be blatantly doing what Bush quietly attempted in Iraq: surging troop levels to mask negotiating an agreement with the enemy. It remains to be seen, however, whether U.S. policy will be successful in stabilizing Iraq in the long-term—that is, after U.S. payments to Sunni guerillas stop. In Afghanistan, Obama also plans to surge at 17,000 more U.S. troops and send 4,000 additional U.S. trainers for Afghan forces. But to make it a fair fight, Obama is also increasing funding to the Pakistani government, which will inadvertently end up aiding the Taliban and other Islamic militant groups in Afghanistan and Pakistan. Obama is negotiating with some militant groups and, as in Iraq, money is flowing to the enemy. But in Iraq, the money pays the enemy to cease hostilities, whereas in Pakistan, some of the increased aid will help the Taliban and other militant groups fight the United States.

Even before Obama became president and said that the United States would eventually withdraw from Afghanistan, however, the Taliban and their ISI sponsors predicted an ultimate U.S. exit and have acted accordingly. The ISI wants influence in a post-U.S. Afghanistan to counter the potential inroads of its archrival India. The group that is most receptive to Pakistani influence is their long-standing ally, the Taliban. Although the Pakistani government has pledged to quit aiding the Taliban, its long-term interests run counter to this promise.

Originally losing sight of the goal of getting Osama bin Laden (who is probably in Pakistan, not Afghanistan), the U.S. has enmeshed itself in a nation-building quagmire in which it is indirectly funding the guerillas fighting its own forces. Instead of surging forces and trainers to Afghanistan and aid to Pakistan, Obama needs to withdraw U.S. forces from Afghanistan—sooner rather than later—and to drastically narrow his goal: to merely guarantee that al Qaeda cannot use Afghanistan or Pakistan as a launching point for attacks on the United States. He is thinking more realistically and clearly about the Af-Pak situation than Bush, but needs to go further.