THE DEATH of 16 U.S. Special Operations troops and at least two members of a reconnaissance team they were seeking to rescue last week in Afghanistan was the largest American combat loss in that country since the beginning of the U.S. intervention there in 2001. It was also a jarring reminder for anyone who has not been following developments in the smaller of the two ground wars the United States is fighting. As in Iraq, violence by local insurgents and foreign terrorists has been surging in Afghanistan this spring and summer, along with American casualties. And once again, confident declarations by senior U.S. officials that the enemy was nearly broken have proved premature.

In April the former senior U.S. commander in Afghanistan, Lt. Gen. David Barno, described his opposition as a "small, hardcore remnant of the Taliban," and he predicted that most of it would collapse or join the Afghan political process within a year. Instead the Taliban has launched an offensive including near-daily attacks, some by well-armed units numbering in the scores. Senior Afghan officials concede they have been surprised by the scale of the campaign. In the past three months more than 45 U.S. service members, as well as hundreds of Afghan soldiers and civilians, have died. The insurgents have begun using the roadside bombs so common to Iraq; they may be getting help from other Afghan factions opposed to the U.S.-backed government of Hamid Karzai, as well as from al Qaeda and other foreign volunteers.

The bright side of this troubling picture is that the Taliban has not succeeded in gaining significant territory or public support, and so far seems unlikely to accomplish its evident aim of disrupting the next round of Afghan elections, planned for September. Despite the attacks, voter registration is proceeding, and some 6,000 candidates are competing for seats in a national parliament and 34 provincial councils. U.S. forces, together with an Afghan army numbering more than 20,000, have been winning lopsided battles against the enemy forces they encounter; they have reportedly killed more than 450 since March. With the heavier fighting, however, have come new reports of collateral civilian casualties. Yesterday the Afghan government criticized the U.S. military for a bombing raid near the site of last week's fighting that may have killed several civilians. To its credit, the Pentagon acknowledged civilian as well as enemy casualties from what it described as an attack on a terrorist base, and it promised to investigate.

In all, the danger is growing that Afghanistan could begin to look more like Iraq, with an entrenched insurgency that seriously disrupts reconstruction and becomes a magnet for Islamic extremists. To prevent that, the Bush administration needs to bring more pressure to bear on Pakistani President Pervez Musharraf, a nominal ally who has pocketed billions in U.S. aid while allowing the Taliban to use Pakistan as a base for its Afghan operations. Afghan officials plausibly suspect that elements in Mr. Musharraf's army and government would like to see the coming elections disrupted. The administration must also continue to press its NATO allies to step up their deployments to Afghanistan, which currently amount to only 8,000 troops, compared with roughly 20,000 Americans. If the Taliban can be turned back before the elections, Afghanistan could take a major step toward stability. For now, the worry is that a turn in the other direction appears equally possible.