A group of U.S. diplomats arrived in Libya three years ago to a memorable reception: a throng of cheering men and women who pressed in on the startled group "just to touch us and thank us," recalled Susan Rice, President Obama's national security advisor.
The Libyans were emotional because the U.S. and its allies had toppled leader Moammar Kadafi in a military campaign that averted a feared slaughter of Kadafi's foes. Obama administration officials called the international effort, accomplished with no Western casualties, a "model intervention."
But in three years Libya has turned into the kind of place U.S. officials most fear: a lawless land that attracts terrorists, pumps out illegal arms and drugs and destabilizes its neighbors.
Now, as Obama considers a limited military intervention in Iraq, the Libya experience is seen by many as a cautionary tale of the unintended damage big powers can inflict when they aim for a limited involvement in an unpredictable conflict.
"If Iraq and Afghanistan are examples of overkill and overreach, Libya is the reverse case, where you do too little and get an unacceptable result," said Brian Katulis, a Middle East specialist at the Center for American Progress, a think tank. "The lesson is that a low tolerance of risk can have its costs."
Though they succeeded in their military effort, the United States and its North Atlantic Treaty Organization allies fell short in the broader goal of putting Libya on a path toward democracy and stability. Exhausted after a decade of war and mindful of the failures in Iraq, U.S. officials didn't want to embark on another nation-building effort in an oil-rich country that seemed to pose no threat to Western security.
But by limiting efforts to help the new Libyan government gain control over the country, critics say, the U.S. and its allies have inadvertently helped turn Libya into a higher security threat than it was before the military intervention.
Libya has become North Africa's most active militant sanctuary, at the center of the resurgent threat that Obama warned about in a May address at West Point. A 2012 terrorist attack against the U.S. diplomatic compound in Benghazi killed four Americans, including Ambassador J. Christopher Stevens.
Arms trafficking from Libya "is fueling conflict and insecurity — including terrorism — on several continents," an expert panel reported to the United Nations Security Council in February. Weapons smuggled out of Libya have been used by insurgents in Mali, by Boko Haram terrorists in Nigeria and by Palestinian militants in the Gaza Strip.
More than 50,000 people, including refugees from Syria and migrants from North Africa, have flooded into Europe through Libya's porous borders, sharpening the continent's immigration crisis.
The latest U.S. State Department travel warning portrays Libya as a society in near-collapse, beset by crime, terrorism, factional fighting, government failure and the wide availability of portable antiaircraft weapons that can shoot down commercial airplanes.
U.S. officials, now scrambling to reverse Libya's downward spiral, say blame rests with the Libyans who took control of a country that has proved more dysfunctional than expected.
"In Libya, the bottom line is still that a lot of lives were saved, and Kadafi was removed from power," said Ben Rhodes, deputy national security advisor. "What it's going to take in the long term for Libya to succeed is strategies that build political coalitions and that train forces. Our military action alone wasn't going to be the end of the story. It was the beginning of a new chapter."
Those who argued against the 2011 intervention say problems were foreseeable.
Former Republican Sen. Richard Lugar of Indiana, who argued against the military campaign while serving as ranking minority member of the Senate Foreign Relations Committee, said, "There wasn't enough thought given to how we were going to make sure these people had the security and freedom we wanted them to have."
Obama was initially reluctant to order the intervention, as were several top lieutenants, including former Defense Secretary Robert M. Gates. Gates didn't want to thrust overstretched U.S. forces into a potentially long war over a fractured society, and at one point he threatened to quit over it, he recalled in his memoir, "Duty."
But the move was supported by Rice and then-Secretary of State Hillary Rodham Clinton, who feared a looming humanitarian catastrophe. Clinton was the swing vote, Gates wrote.
Obama insisted that U.S. forces only kick off the air campaign and then give the leading role to Britain and France. The seven-month operation took longer than promised, but when it ended, Obama heralded it as proof that NATO was history's most effective military alliance.
Then the problems began.
The NATO countries, concluding that there were no opposing forces in Libya that needed to be separated, decided for the first time in alliance history not to leave behind an armed stabilization force. Instead, a tiny U.N. mission with no executive authority was left to coordinate international efforts.
The weak Libyan government resisted Western pressure to seal its borders and create a strong army, instead paying a patchwork of militias to do the job. Its leaders brushed aside Western advice on how to restore the economy, sending oil production down 80%.
They also refused to cede control of Kadafi's vast arsenal of weapons. Estimated to include 1 million tons of assault rifles, small arms, antitank missiles, rockets and portable antiaircraft weapons, the cache was bigger than Britain's arms inventory.
As time passed, the crumbling of institutions and the conflicts among the 125 rival armed groups proved much greater than U.S. officials had expected. Violence surged, including kidnappings and attacks on government officials.
"We were all taken by surprise, when Kadafi left, by the sheer lack of government institutions," Anne Patterson, the top U.S. diplomat for the Middle East, told a congressional panel Wednesday.
After the attack in Benghazi in September 2012, the U.S. and other Western countries cut staff in Libya, further hobbling recovery efforts.
The administration's top priority now is an eight-year plan to train a force of up to 8,000 soldiers. But one year after Libya requested the help, the program hasn't begun because it is too dangerous for the trainers to enter Libya and the dysfunctional government has been unable to raise the money.
As the Obama administration struggles with several other international crises, it is clear that the Libya conflict is considered a second-tier issue.
Last month, Clinton was asked at a Council on Foreign Relations event why the United States didn't do more to mend Libya, since the U.S.-led military campaign had broken the old order.
"We did try," she said. "That is a perfect case where people who've never had that opportunity to run anything, manage anything, even participate in meaningful politics, understandably are not even sure what questions to ask."
Some observers are warning that the administration eventually may be forced to do more. A Rand Corp. report this spring predicted that if Libya's problems continue to worsen, another NATO intervention might be required.
"Libya is a lesson about the risks," said Robert Danin, a longtime U.S. diplomat in the Middle East who warned about the risks of ensuing chaos. "With nation-building in disrepute, there's a tendency now to want to declare victory and move on. But interventions can't be done neatly."