THE DEATH of Moammar Gaddafi, which prompted jubilation in Tripoli and relief in Western capitals on Thursday, must be seen as the beginning and not the end of Libya’s transformation. The elimination of the dictator reduces the chance of a prolonged insurgency against Libya’s new authorities, who have pledged to create a liberal democracy and hold elections in eight months. But what remains is a shattered country piled high with dangerous weapons, lacking legitimate institutions or civil society, and vulnerable to tribal, regional, sectarian and even racial rivalries.

The good news is that, in the time it took to depose Mr. Gaddafi, the Libyan opposition created a Transitional National Council recognized by 80 governments and prepared an ambitious but reasonable transition plan. Its leaders have pledged to form a new administration after Mr. Gaddafi’s downfall and not to serve in the future government. Civil society groups, free media and political parties have begun to form in the eastern half of the country, which has been free since last winter. And the new government should soon be able to draw on tens of billions of dollars in reserves held by foreign banks.

The threats begin with the more than two dozen rebel militias that participated in the fighting and that now coexist uneasily in Tripoli and other cities. Not all have been integrated into the chain of command under the transitional council; some commanded by Islamists have received their own weapons and funding from the Persian Gulf emirate of Qatar, according to a report by the Wall Street Journal. The often-undisciplined militias have abused and even tortured prisoners and suspected Gaddafi supporters, Human Rights Watch reported. Mr. Gaddafi himself may have been killed after having been captured on Thursday.

Added to this volatile mix are huge stockpiles of weapons, including thousands of surface-to-air missiles and chemical arms, acquired by the Gaddafi regime. Many have been unsecured for weeks, and some have already been smuggled across Libya’s borders. The Obama administration rightly has focused on this problem, dispatching civilian contractors to help track down the weapons and dedicating $40 million to the effort.

Consistent with the administration’s policy of following rather than leading in Libya, Secretary of State Hillary Rodham Clinton’s visit there Tuesday came months after those of European counterparts. But it turned out to be timely, as Ms. Clinton conferred with Libya’s new leaders just 48 hours before Mr. Gaddafi’s final downfall. Ms. Clinton recognized the scale of the challenges: “Now the hard part begins,” she told interim Prime Minister Mahmoud Jibril.

But the U.S. assistance she offered was modest: some medical aid and scholarships for students in addition to the weapons hunt. Libyan leaders are eager for a more active American role, recently telling visiting senators that the transitional council would pay for a U.S. training mission for security forces.

The administration should respond positively: Libya’s stabilization under a democratic government could help tip the broader wave of change in the Arab Middle East toward those favoring freedom. “Would you see the U.S. taking the lead in terms of rebuilding this country and helping?” a Libyan student asked Ms. Clinton. The answer should be “yes.”