Political junkies are betting these days as to how certain events would affect the election, such as a terror attack or a major crisis in Iraq.

To these I would add one event that is almost certain to take place: the October election in Afghanistan. How that vote takes place -- with chaos and violence or order and celebration -- will have a significant effect on President Bush's electoral fortunes. Here, as in Iraq, he must now wish he had listened to wiser voices sooner.

After the United States won its spectacular victory against the Taliban in December 2001, it assured the world that it was committed to intensive efforts to rebuild Afghanistan. But policy on the ground was largely controlled by the Defense Department, whose civilian leaders rejected nation-building. They saw the mission in Afghanistan as narrowly military -- fighting the Taliban -- and perhaps wanted to move troops out of Afghanistan to prepare for an invasion of Iraq. During 2002 the United States did not extend the reach of the international security force outside Kabul, was wary of asking NATO to get involved, provided little funding for reconstruction and, most crucially, refused to help in the demobilization of the Afghan militias.

These decisions had two effects: the first was to embolden Afghanistan's warlords and tighten their grip on power. In the aftermath of the war, their powers could have been defined so as to allow a central government to develop basic elements of national life, such as the rule of law, a national economy and a set of political institutions. Instead, the United States had a laissez-faire policy. The warlords were the only ones other than the United States with military power on the ground. They noticed the development of a political vacuum, expanded their powers and broadened their reach.

The second, related effect of America's tunnel vision was that the drug trade began booming. Afghanistan now supplies 75 percent of the world's opium. The warlords saw a ready source of revenue, outside the reach of Kabul, and encouraged the trade. Drugs are now the dominant feature of Afghanistan's economy, half as big as the legal economy. Worse, the trade is now moving from opium to heroin, which means that it's connected with international cartels, crime and big money. The amounts of cash involved dwarf government revenue, and corruption has infected every aspect of Afghan political life.

The Defense Department's aversion to any political role in Afghanistan was criticized -- by President Hamid Karzai and his allies (quietly), the State Department, U.S. senators such as Joseph Biden and John Edwards, U.N. officials and nongovernmental organizations. Then the military on the ground began making the case that it could not achieve its goals without political stability and economic development. Even then, when Karzai presented Defense Secretary Donald Rumsfeld with a plan to take on certain key warlords in May 2003, Rumsfeld declined to offer U.S. support. (Yes, all this eerily echoes what later happened in Iraq.)

About a year ago, policy began shifting, partly pushed by the new U.S. ambassador, Zalmay Khalilzad, a former Pentagon official who is trusted by Rumsfeld. The United States asked NATO to get involved, began gingerly accepting the idea of expanding the reach of the international force, promised increased resources and, crucially, began supporting demobilization.

Disbanding the warlords' forces is the key challenge facing Afghanistan. The political scientist Max Weber once defined a state as that entity that has a monopoly of the legitimate use of force in the country. In Afghanistan, the state has no such monopoly. Winding down militias is the only path to that goal. The Pentagon had made it so clear that the United States would have nothing to do with this that Lakhdar Brahimi, the United Nations' special envoy, used to jokingly call it "the American fatwa" on demobilization. By the end of 2003 the fatwa was revoked. Now, finally the United States is assisting in the process, urging warlords to disband their militias and incorporate into the new Afghan army.

There are other positive trends in the country. Afghans have approached the national elections with huge enthusiasm, exceeding all predictions of voter registration. Polls show that they are highly supportive of Karzai, the United States and the international efforts at reconstruction. The problem in Afghanistan has not been with the Afghans but with the U.S. government.

U.S. policy toward Afghanistan is now on the right track. America and its allies are extending security outside Kabul, helping to build up the Afghan army and police, weakening the warlords, strengthening the central government, funding reconstruction projects, offering farmers alternatives to opium. But it may be too late. Instability is rampant, the drug trade is flourishing and the warlords are entrenched. As in Iraq, the administration seems to have learned from its mistakes, but the education of George Bush has been mighty costly.

comments@fareedzakaria.com