A good outcome is still possible in Libya; the decision this morning by a coalition of Western and Middle Eastern states to recognize the transitional government in Benghazi is an important step forward. But success will require patience and persistence from NATO, creativity from the United States, and pragmatism from the rebels. And there is good reason right now to worry about each of those things.

In order to picture the current state of the military campaign in Libya, imagine three lines representing the will and capacity of, respectively, Muammar al-Qaddafi’s security forces, the rebels, and NATO. Each line has a different slope, and they will eventually cross.The good news is that Qaddafi’s capacity is almost certainly diminishing. A senior NATO official tells me that "60 to 70 percent of Qaddafi’s military stocks are destroyed," while "economic sanctions are biting as gasoline diminishes daily in Tripoli." U.S. officials familiar with the intelligence claim that the rebels’ attacks on the main pipeline from the main oil refinery at Zawiyah* has sharply reduced Qaddafi’s access to fuel, while financial sanctions have prevented him from securing the funds to buy oil on the international energy market. Nevertheless, Qaddafi has proved much more resilient than most people expected. His grip on Tripoli is not threatened, and the stream of high-level desertions he suffered early in the conflict has slowed to a trickle.

The rebels have all the will in the world, but the growth in their military ability has been frustratingly slow. Despite optimistic bulletins from the front that the war will be won in a matter of weeks, their own leaders concede that they’re not remotely ready for a direct assault on Tripoli, which in any case would result in massive casualties. Unless the Qaddafi regime implodes, the rebels will have to depend for a long time to come on NATO. But can they?

Four months into the aerial campaign — already six weeks longer than the 1999 air war over Kosovo — NATO’s arms inventory is running down, albeit far less dramatically so than Qaddafi’s. U.S. Defense Secretary Leon Panetta asserted on July 11 that "a lot of these countries" could run through their stock of missiles within 90 days. And patience has begun to dwindle along with stockpiles. Though France has taken the most bellicose posture of any of the allies, French Defense Minister Gerard Longuet recently said that the time had come for the rebels to "get round the table" and negotiate with the regime. This sounds like a sharp change in tone, but when I asked a French diplomat about his country’s policy he pointed me to comments by Foreign Minister Alain Juppe on July 11 reiterating the position that Qaddafi can have no place in a future Libyan government. France, he insisted, remained resolute: The National Assembly just voted 482 to 27 in favor of continuing with the bombardment.

American officials are plainly worried about the diminishing line of will. A State Department official pointed out that Qaddafi has a genius for exploiting difference among the allies. At today’s meeting in Istanbul of the Libya Contact Group — an ad-hoc assembly of representatives from NATO and Middle Eastern country and international organizations that convened regularly since April to chart a course forward with the conflict — Secretary of State Hillary Clinton strove to keep the alliance "speaking with one voice," according to this official.

But what will that voice be? Will it be, "Keep fighting until the rebels win, or Qaddafi flees?" Qaddafi has been indicted for war crimes by the International Criminal Court. Where would he flee to? Zimbabwe? Marina Ottaway, a Middle East expert at the Carnegie Endowment, says, "We have to accept a solution which is not exactly what we had in mind to begin with." In this scenario, NATO would keep up the bombardment while U.N. officials and rebel leaders work out a political solution in which Qaddafi leaves power, but not Libya. Qaddafi just might accept such an outcome; Juppe, in Istanbul, said that "The Libyan regime is sending messengers everywhere, to Turkey, to New York, to Paris" seeking a negotiated solution.

Could the rebels live with it? A rebel leader whom I heard speak last month recalled growing up in Benghazi seeing bodies swing from lampposts. Neither she nor her colleagues were prepared to sit around a table with the monster who was responsible. And how can they possibly trust that Qaddafi would sit quietly inside his compound? What about his sons? Would they sit there with him? But if the only alternative is six more months of war, the rebels may have to sign on to such a plan, if only to preserve the NATO alliance which they can not currently live without.

What if Qaddafi lies and dithers, as in all likelihood he will, and the talks go nowhere? Then NATO will have to keep inflicting damage, and the rebels will have to get better. And this is where the United States comes in. The government in Benghazi, known as the Transitional National Council (TNC), has asked the allies for $3 billion in order to pay salaries and to buy military supplies, food, medicine and other basics. With sufficient funding, the rebels could not only improve their military capacity but, just as importantly, demonstrate to the Libyan people that they have the ability to deliver services and run a government, as Qaddafi himself never did.

The U.S. government has frozen $30 billion in Libyan assets, and would like to divert some of that money to the rebels. Today’s decision to formally recognize the TNC as the legitimate government of Libya will make it much easier to do so. But the American diplomat I spoke to noted that political recognition is not the same as legal recognition; the TNC may not qualify as a recognizable government according to State Department criteria. What’s more, even legal recognition might not, by itself, permit the assets to be unfrozen. "We’re really grappling with it right now," he says.

But the problem may be political as well as legal. "We’re paranoid about the possibility of Islamic infiltration," says Marina Ottaway. For months, critics of the decision to bomb Libya, as well as many on the right, have wrung their hands over the rebels in Benghazi, saying, "We don’t know who they are." Now, after extensive reporting, we know who they are: people from all walks of life, including a great many professionals, who loathe Qaddafi and yearn for a better life — and yes, some Islamists, too. Behind the NATO-enforced cordon sanitaire in front of Benghazi, a chaotic laboratory of democracy has sprung up. Benghazi has 400 non-government organizations and 40 or so proto-parties. There are endless meetings, debates, committees. The Tripoli Task Force, a TNC-appointed committee of independent experts, makes plans — quite serious, specific plans — for Day One of the post-Qaddafi world. Whatever its inevitable shortcomings, this is a struggle which undoubtedly deserves the support — not just moral, but also financial — of the West.

The critics of humanitarian intervention who say that the outcome is likely to be messier and more protracted than its proponents imagine are right. You have to be prepared to live with the unforeseen consequences of your acts. NATO and the United States thus have to stay the course not only to deliver the Libyan people from Qaddafi but also to demonstrate that such interventions are not exercises in imperial hubris — or "wars of whim," as my Foreign Policy colleague Stephen Walt mockingly puts it. The imperative of preventing mass slaughter in Benghazi was reason enough to act — though Walt writes breezily of "the fear of a possible ‘bloodbath,’" as if this were a flimsy pretext seized upon by reckless adventurers. But with hundreds now dying on both sides, it would be grotesque to declare the effort a success if Qaddafi holds onto power. The war in Kosovo succeeded — insofar as it succeeded — not because it halted ethnic cleansing, but because it freed Kosovars from Serbian control.

A post-Qaddafi Libya will be a mess, as post-Milosevic Kosovo has been. But it just might be a very inspiring mess. And the Obama administration and its NATO allies have it in their power to help deliver such an outcome.

*Correction: An earlier version of this story mistakenly reported that Libya’s rebels controlled the rifinery at Zawiyah.