KABUL, Afghanistan — It seemed so easy five years ago: Anti-Taliban forces rolled into Afghanistan's capital after a monthlong American bombing campaign, and the repressive Islamist regime scattered like leaves in autumn.

With the Taliban gone, many Afghan men shaved their beards and some women cast off their burqas. But Osama bin Laden and the architects of Sept. 11 slipped away in eastern Afghanistan, and that should have been a clue to how elusive objectives can be in this fractious nation.

America turned its attention and resources to Iraq. But today the Taliban remnants have mutated into a different force — far deadlier, better organized and well-armed. With close bonds to the al-Qaida international Islamist network, the insurgents have imported new skills previously unseen in three decades of war in Afghanistan — remote-control roadside bombs and suicide bombers.

Here, where the war on terror began after the Sept. 11 attacks, a cold, hard reality has set — the battle has become a protracted counterinsurgency campaign that international officials say won't be resolved for years, even decades.

"This is not linear at all," said Army Lt. Gen. Karl Eikenberry, the commander of the American-led coalition in Afghanistan. New forces have entered the mix — tribal chiefs, opium traffickers and extremists experienced from the Iraqi conflict. "All this fuels on a militant ideology that has a way of resonating with the people here."

Afghans complain that American policymakers paid too much attention to capturing a few high-value targets like bin Laden, and not enough to addressing the more complex social and economic problems that made Afghanistan a welcome environment for Islamic extremists.

"I think that it was very naive to believe after the fall of the Taliban in 2001 that was the end of the Taliban," Afghan Foreign Minister Rangeen Dadfar Spanta said in an interview. "That was the reason why they concentrated only on the military action against the Taliban. But anti-terror is a comprehensive project."

The top United Nations diplomat in Afghanistan agrees.

"Maybe it was a bit simple to think you could just extinguish this flame by sort of pushing them out or blowing them out," said Tom Koenigs, the head of the United Nations Assistance Mission in Afghanistan. "We were maybe too shortsighted."

Despite the trappings of democracy — elections, a new Parliament, a new constitution — Karzai's government is hampered by rampant corruption, growing insecurity and runaway opium production. The enthusiasm that accompanied him into office after elections two years ago has waned.

But Afghanistan is not without progress.

After the fall of the Taliban, many feared that civil war would break out between rival ethnic and political factions, as happened previously in Afghanistan and has since occurred in Iraq. That hasn't happened. Karzai has held his weak government together, but at a cost — by striking a Faustian bargain to accommodate warlords, many of whom are now the sources of the discontent and insecurity that bedevil the government.

Afghanistan no doubt is a far different nation than it was five years ago when the repressively puritanical Taliban was toppled.

In the capital, foreign troops, aid workers and returning refugees have imported an international flavor. There are now diversions unknown during the Taliban time — movies, private television and cell phones. Music blares from wedding halls, and private vehicles fill the streets. Simple pleasures forbidden by the Taliban — kite-flying, furtive flirting among couples on picnics in the park — are now taken for granted.

But the foreigners also imported un-Islamic temptations — alcohol, prostitution, revealing clothing — that provide evidence for Taliban propagandists that Afghanistan has become a Western outpost of sin.

Cities like Kabul, Jalabad and Herat are experiencing construction booms, some of it no doubt funded by money from the burgeoning opium trade. Economists estimate that Afghanistan's drug economy is half as large as the legitimate economy, making impoverished Afghanistan more dependent upon an illicit enterprise than any other nation in the world.

In Kabul, where apartment blocks are rising amid the ruins, the old and the new collide sometimes in comical tableaus — at the marble-and-chrome Kabul City Center, traditionally dressed provincial Afghans shriek and stumble as they experience escalators for the first time.

Though women do not enjoy the liberties they had during Afghanistan's Soviet occupation in the 1980s, they have re-entered the workplace. About 1.6 million girls have gone back to school. Women won 28 percent of the seats in Parliament's lower house, six more than the 25 percent the new constitution guarantees.

Millions of Afghans have returned from exile in Pakistan, Iran, Europe and America. They brought with them foreign expertise and broader world-views. But they also brought competition for scarce resources. Real estate prices have skyrocketed in the larger cities, and the poor have been forced out farther to the outskirts. In rural areas, disputes have broken out between nomadic Kuchi herders and returning refugees reclaiming their lands.

U.S. AID has invested $3.7 billion in Afghanistan since 2001, though many Afghans complain that much of the assistance has been wasted. American money has helped construct or refurbish more than 1,000 schools and clinics, enrolled 5.3 million children in school, extended access to basic health care to 80 percent of the population and built more than 600 miles of regional and local roads.

But in a country where expectations for prosperity and peace are very high, the efforts often fall short. With the power system unimproved, the sidewalks in Kabul's business district are filled with sputtering portable electrical generators supplying storefronts and offices.

"There have been huge delays in building basic infrastructure," said Barnett R. Rubin of New York University, a leading author and scholar on Afghanistan.

"Kabul city now has less electricity than it did during the Soviet occupation. And no more really than it did when the U.S. came in there."

Much of the countryside remains untouched by Karzai's government, providing a vacuum into which the Taliban has moved.

"If this government is able to present an alternative, people haven't seen it," said Scott Braunschweig, the advocacy coordinator for Care International, which has a staff of 1,200 and a $25 million budget in Afghanistan alone.

Eikenberry, the top American military official in Afghanistan, says he understands the concerns. He testified before the House Armed Services Committee in June that the key to defeating the resurgent Taliban is to develop Afghanistan's economy.

"If you were to ask me the question, would it be more important to have a U.S. infantry battalion of 600 on the ground or $50 million for roads, we could deliver more security with $50 million of additional roads being put in," Eikenberry testified.

The role of the coalition forces has changed remarkably in the last five years. "We've never had a mission of this type, building a whole system," Eikenberry said in an interview last week. "This has been a pretty massive enterprise."

Washington initially sent in a force of only 8,000 troops, primarily to pursue international terrorists like bin Laden. The military deliberately refrained from attempting to maintain security or public order, leaving that chore to Afghan militias with whom it had been allied to overthrow the Taliban.

Five years later, nearly 40,000 foreign troops are struggling to contain an insurgency that persists along most of the 1.500-mile border with Pakistan, particularly in the south.

Coalition forces under Eikenberry's command now number about 21,000, of which all but 2,000 are Americans. NATO has an additional 18,500 troops in Afghanistan — 2,000 of them are Americans.

At the end of July, NATO took over security in southern Afghanistan, where British, Canadian and Dutch troops have faced fierce fighting. Its command will expand to encompass the entire country later this year, including control of about half the American troops. The remaining 10,000 Americans will remain under direct U.S. control as a counter-terrorism force along the border.

America's early reliance upon Afghan ethnic militias has had a lasting negative legacy. Most Afghans hate the warlords, who destroyed Kabul before the Taliban pushed them aside in 1996.

"The most popular thing the Taliban had done was to drive those militias out of power, and then we brought them back," said Rubin, the Afghan expert who served as an advisor to the U.N. special representative for Afghanistan, Lakhdar Brahimi, in 2001.

Though the international coalition is gradually sidelining unreconstructed warlords, the drug trafficking and thuggery that thrived under their rule has been difficult to dislodge.

The coalition forces themselves have helped reinforce the impression of Karzai's weakness by operating with freedom of movement, unaccountable to the national government.

"There's just an obvious contradiction between building up an independent sovereign government on the one hand and maintaining a military force that operates on that state's territory without being under the command of that government," said Rubin.

Under growing political pressure to confront the Americans, Karzai in the last year has demanded that coalition forces restrain the use of aerial bombings and the house searches that have alienated Afghans. But each incident — such as the U.S. truck accident that sparked off deadly riots in May — has ignited renewed denunciations of American military arrogance.

"People have lost their trust, and the Americans are losing support," said Zaman Malang, a military commander who represented a delegation of Kunar province villagers visiting Karzai last week to complain about an American raid in August that left eight people dead, including a 12-year-old boy.

The coalition's long-term strategy is to build up the Afghan National Army to eventually take over security functions — so far about 30,000 Afghans out of a planned force of 50,000 have gone through training and are deployed alongside American and NATO units.

But the coalition only belatedly recognized it also needed to train police, who are notoriously corrupt in some areas and work hand-in-hand with the Taliban in others.

"Without the police, the military operations in a sense are futile," said Rubin.

The United States last year took over police training, but officials say it will take at least two years before 62,000 officers are sufficiently prepared.

Afghans say their reconstruction efforts would be far easier if the international community could only confront the biggest problem of all — the Taliban's continued freedom to operate from bases in Pakistan's tribal areas.

The Pakistanis last week struck a deal with pro-Taliban rebels in a tribal region bordering Afghanistan: The militants agreed to stop raids in both Pakistan and across the border. On a visit to Kabul on Wednesday, Pakistan President Pervez Musharraf vowed to help Afghanistan crush the Taliban.

But Afghans are deeply skeptical of Pakistani motives, and the issue likely will be taken up later this month with President Bush when Karzai and Musharraf are both scheduled to appear before the United Nations in New York.

Despite the problems, Afghans and Americans maintain Afghanistan is no Iraq — the Taliban remain largely unpopular, and most Afghans recognize the international forces must remain in Afghanistan until the reconstruction takes root.

Koenigs of the United Nations said the international community, which earlier this year pledged commitments to Afghanistan for five years, remains united.

"We have a consensus among the capitals about the magnitude of the challenge," said Koenigs. "I'm absolutely sure they have to stay another 10 years."

Koenigs suggests the foreign troops may have to stay even longer — until Afghanistan becomes integrated into a regional security structure like the African Union, in which neighboring countries can work out their problems diplomatically without resorting to proxy wars and subterfuge.

Unfortunately, no such organization exists in the volatile region surrounding Afghanistan. "We are far from that," said Koenigs.