Despite the progress of the U.S.-led military campaign in Afghanistan, events nearly a decade ago in Somalia underscore that it takes more than technology, money and good intentions to bring stability to a nation wracked by violence and internal disputes.

Like Somalia, which descended into factional fighting after the 1991 overthrow of the 21-year dictatorship of Mohamed Siad Barre, Afghanistan will be another test for attempts at nation-building in the post-Cold War era, analysts say.

Both are impoverished Muslim nations that have endured decades of turmoil. Behind their conflicts lie the strong tribal-clan affiliations that form the fabric of both societies.

The U.S.-led coalition in Afghanistan is going well so far, but an initially successful humanitarian intervention in Somalia in 1992-95 ended in failure for both the United States and the United Nations when U.S. troops tried to intervene in Somalia's internal affairs.

Eighteen American soldiers were killed in an October 1993 raid in Mogadishu that captured two aides to a leading warlord. Two U.S. helicopters were shot down, and Americans were horrified by photos of Somalis dragging a dead soldier through the streets.

Washington soon pulled its troops from Somalia, leaving a weakened U.N. peacekeeping force that had little impact before finally withdrawing in 1995.

The problem in Somalia was a lack of understanding of the country by both the United Nations and the U.S. government, said Robert Oakley, a former U.S. ambassador to Somalia.

Upon his inauguration in January 1993, President Clinton inherited the Somali mission, which had started a few months earlier as a U.N. aid operation supported by U.S. troops to get food to starving Somalis after factional warfare plunged the country into chaos.

But in May 1993, the mission was changed to one of active peace enforcement.

The Clinton administration and the United Nations decided to turn Somalia into a democracy, Oakley said, but they failed to understand that pushing Somali warlords too hard would create a backlash.

Critically, as the political goals expanded, the number of U.S. troops in Somalia fell from 20,000 in January 1993 to about 1,000, and many countries that had contributed peacekeepers balked at active military operations, Oakley said.

There are critical differences between Somalia and Afghanistan, however. There was little public support in the United States for the operation in Somalia, but Americans seared by the images of Sept. 11 strongly back the military campaign against Afghan-based terrorist groups and their Taliban protectors.

It remains to be seen whether they will have the patience for the more complicated nation-building that could turn bloody.

U.S. leaders have been at pains to prepare the U.S. public for a long anti-terrorist war that will bring American deaths.

At a Pentagon news conference Friday, Secretary of Defense Donald H. Rumsfeld again warned that ''there will be further casualties in this campaign, in Afghanistan and elsewhere.''

''But it will not deter us for a day or for a moment from our objectives,'' he said.

There has been speculation that Somalia, where Osama bin Laden's operatives are reported to have been involved in anti-American activities in the early 1990s, could become a target if the United States does broaden the war on terrorists.

For now, as U.S. troops and anti-Taliban Afghans carry on the war in Afghanistan, the international community is working to form a transitional government there and possibly win agreement from the numerous factions to accept a foreign peacekeeping force.

Somalia, large areas of which remains lawless and violent, is a sad lesson of what can happen when the international community fails, said Mohamed Osman Omar, an adviser to Abdiqasim Salad Hassan, who was elected interim president by Somali clan leaders in August 2000 but who still has little sway in a country where warlords control many areas.

In both Somalia and Afghanistan, problems surfaced when groups that worked together to oppose a ruling regime failed to unite to form an alternative after its ouster, leaving the countries divided into clan-based fiefdoms ruled by warlords, Omar said.

''When they find the gold mine (power), they start shooting each other,'' he said.

David Stephen, the U.N. representative for Somalia, said in dealing with such countries the international community has to find a balance between ''tutoring, interference and encouragement.''

''The main problem was perhaps the international community's trying to impose things the Somalis and some members of the international community did not want,'' he said.