Smoke fills the sky over Tripoli after rockets fired by one of Libya's militias struck and ignited a tank in the capital's main fuel depot, Tripoli, Libya, 03 August 2014. The Libyan Health Ministry said that 179 people have been killed in clashes over the last week in Tripoli following a struggle between rival militias over control of the capital's airport and in the eastern city of Benghazi where according to media sources Government troops continue to fight Islamist militias. (Sabri Elmhedwi/EPA)

THREE YEARS after U.S. and NATO forces helped liberate Libya from the dictatorship of Moammar Gaddafi, the country is beginning to look a lot like another nation where an abrupt U.S. disengagement following a civil war led to chaos: Afghanistan in the 1990s. In Libya, heavily armed militias are battling for control of Tripoli and Benghazi as well as the international airport. The United States, France and other Western governments involved in the 2011 military intervention have evacuated their diplomats and abandoned their embassies. A U.N. mission that was supposed to help broker political accords also left.

Last month in Benghazi, the Ansar al-Sharia militia, which has ties to al-Qaeda and was involved in the Sept. 11, 2012, assault that killed the U.S. ambassador there, stormed a military base and then declared the city the seat of an “Islamic emirate.” That’s what the Taliban called Afghanistan. According to The Post’s Karen DeYoung, some U.S. counterterrorism officials believe Libya’s Islamists could seek to align themselves with the Islamic State, the al-Qaeda offshoot that controls western Iraq and eastern Syria. Whether or not that happens, it’s not hard to foresee eastern Libya becoming a launching pad for terrorist attacks against nearby Europe or even the U.S. homeland.

U.S. and Western responsibility for this mess is heavy. Having tipped the outcome of the war against the Gaddafi regime, NATO quickly exited Libya, which was left with no army or political institutions but was awash in weapons. Repeated Libyan requests for assistance in restoring security were brushed off; a small-scale NATO training program based outside the country was little more than symbolic. As in the case of Afghanistan, Congress rejected the Obama administration’s aid requests.

Libya’s attempt to establish a working democracy, meanwhile, was overtaken by infighting among militias, which slowly polarized along an Islamist-secular divide. Libyans appear to prefer secular government: Islamists fared poorly in a parliamentary election held in June. But their military forces, which include a militia from the coastal city of Misurata as well as Ansar al-Sharia, are formidable.

The Obama administration has done its best to ignore Libya’s collapse, even as Republicans in Congress obsess over conspiracy theories about the 2012 Benghazi attack. Administration officials continue to peddle the empty line that “Libya’s challenges can really only be solved by the Libyans themselves,” as Secretary of State John F. Kerry put it this week. Officials point to the newly elected parliament, which convened in the eastern city of Tobruk last weekend, as a possible vehicle for a political settlement.

That’s hardly likely. Pacification of Libya would probably require another Western intervention and a peacekeeping force, coupled with a far more robust international mediation mission. The chances that such an intervention will be mounted, of course, are minuscule; the Obama administration would almost certainly not endorse it.

Of course, the notion that the United States should intervene against the budding al-Qaeda menace in Afghanistan during the 1990s also was dismissed as fanciful. After the attacks of Sept. 11, 2001, recriminations were plentiful. Yet the lessons of Afghanistan seem to have been lost in U.S. policy toward the contemporary Middle East.