The pair of counter-terrorism raids carried out by U.S. special forces in Libya and Somalia over the weekend are a reminder that the war on terrorism continues to be fought on a global stage against enemies who operate largely independently of the nation states in which they are found. But the very different outcomes of the two actions suggest the difficulty of countering threats in countries where weak governments can't fully control their own territory and where putting American boots on the ground will always be fraught with risk and uncertainty.

The special forces operation in Libya was a textbook example of a foreign counter-terrorism operation that went off virtually without a hitch. The target, a high-level al-Qaida operative known as Abu Anas al-Libi, had long been a target of U.S. counter-terrorism officials, who accuse him helping plan the 1998 bombings of the U.S. embassies in Kenya and Tanzania. On Saturday, as Mr. Libi returned home from morning prayers at a mosque, special forces troops snatched him off the streets of Tripoli and spirited him away without firing a shot.

Mr. Libi and his family had been living more or less openly for months in the city unmolested by Libyan security forces. It's still not clear whether Libya's weak provisional government collaborated with the U.S. in the capture Mr. Libi — Libyan officials deny that — or whether it simply turned a blind eye to his presence in the country, as Pakistan may have done with Osama bin Laden during the decade before he was tracked down and killed by special forces unit SEAL Team 6. In either case, the operation was a stunning success that avoided any collateral damage in the form of civilian casualties — the only thing that appears to have been broken was Mr. Libi's car window. Meanwhile a key terrorist suspect was taken into custody with the potential to provide U.S. officials with a treasure trove of intelligence about al-Qaida operations.

The raid in Somalia to capture a suspected al-Shabab commander turned out less well. The operative, known as Ikrimah, was believed to have been involved in at least one of the 1998 embassy bombings in Africa as well as the 2002 attacks on a hotel and airline in Kenya. Members of SEAL Team 6 slipped ashore from the Indian Ocean under cover of darkness early Saturday but were met with a hail of gunfire from the compound they had targeted. A protracted gunfight ensued, during which several militants were killed before the Americans withdrew. Although no U.S. soldiers were killed, Mr. Ikrimah appears to have slipped away.

The special forces raids underscore the increasingly aggressive tactics U.S. officials appear willing to use against groups that pose a threat beyond the borders of the countries where they are based. Al-Shabab, for example, was relatively low on the administration's list of priorities until the attack last month on a Kenyan shopping mall that killed more than a hundred victims, including many Western civilians. Putting U.S. special forces units on the ground in lawless regions like Libya and Somalia represents an upping of the ante from unmanned drone strikes, which up to now have been one of the most common ways of taking out high-value foreign terrorist targets without risking U.S. lives.

The advantages of pinpoint attacks by special forces units on the ground rather than drone strikes from the air are obvious. For one, they greatly reduce the possibility of killing or injuring innocent people near the target or deaths due to mistaken identity, both of which fuel hatred for Americans among the population and aid the terrorists' recruitment efforts. Secondly, when terrorist suspects are captured rather than killed, U.S. officials can interrogate them for useful information about their group's structure, personnel and planned future attacks.

Of course, the drawbacks of putting U.S. boots on the ground are just as obvious: The risk of death, injury or capture to our troops; the diplomatic complications of mounting military operations abroad in countries far removed from the traditional battlefield; and resentment among the local populace that spawns two new terrorists for every one eliminated through military action. There's no way such dangers can be entirely avoided; they are inherent in any operation involving armed force. The best commanders can hope for is that the potential benefits outweigh the risks, but once the bullets start flying the outcome can never be taken for granted.