AT BEST, PROGRESS in Iraq during the coming months will be uneven, and the options facing U.S. forces will range from unappealing to unthinkable. In that context, a brokered truce that yesterday appeared to have ended, at least for now, the weeks-long battle of Najaf represents as bright an outcome as could have been realized.

The difficulties are well-known. The Iraqi government led by Prime Minister Ayad Allawi has performed relatively well since it took over in June, and it has at least one major factor on its side: Most Iraqis still seem to share the overall goal of shaping a coherent, multi-ethnic democratic state. Mr. Allawi's commitment to hold elections by early next year while seeking to restore as much security as possible is in sync with that goal. But he does not have a strong enough army or police force to deliver as much security as Iraqis expect, and the U.S. and allied troops he must therefore rely upon are deeply unpopular. Meanwhile the enemies of democratic transition, including foreign terrorists, Islamic militants and Saddam Hussein-trained Baathists, may comprise a small minority of the population, but they are ruthless and capable of terrible mayhem and intimidation. Mr. Allawi must navigate these currents while Iraqi forces continue to be trained.

Moqtada Sadr, the firebrand young Shiite cleric whose militia had seized control of Najaf's revered mosque, sought to derail the process. He led an uprising that at one time seemed to be gaining strength through much of Iraq's southern Shiite heartland, and his goals, while never entirely clear, certainly did not include multi-ethnic democracy or a U.S. presence in Iraq. U.S. Marines and soldiers, fighting alongside a small and untested Iraqi force, performed bravely for the past several weeks, inflicting substantial losses on the Sadr forces while taking care not to damage the mosque. If the respected Shiite Grand Ayatollah Ali Sistani had not intervened, U.S. forces were prepared in the next few days to force a final battle, with Iraqi troops assigned to reclaim the mosque itself. Instead, Mr. Sadr was permitted to go free in exchange for vacating the mosque and ordering his militia to lay down their arms.

Is this a defeat for the government? Mr. Sadr is a murderous outlaw, and Iraq would be better off without him. But it's not certain that Iraqi forces could have prevailed in a final battle, at least not without harming the sacred shrine in a way that would have redounded against U.S. forces and the Iraqi government. Now the shrine has been reopened, thanks to the intervention of Mr. Sistani, who worked in cooperation with the Allawi government and who supports the same democratization schedule as Mr. Allawi and the international coalition. Mr. Sadr cannot be trusted to honor any agreement, but he has failed for a second time to derail the process.

Mr. Allawi should take credit for the reopening of the mosque and thank Mr. Sistani for his role. He and his U.S. allies should avoid any future threats they cannot back up, but they must move to regain control of Sunni cities as they moved in Najaf. They also must accelerate the dispensing of U.S. and allied aid in places such as Baghdad's Sadr City slum, which is named for Mr. Sadr's late -- and far more respected -- father, but where the young cleric remains popular. No one should think that yesterday's truce is a turning point toward stability in Iraq. But it has given the allied effort another bit of breathing room.