Libya Dawn fighters fire an artillery cannon at Islamic State militants near Sirte, Libya, last year. (Goran Tomasevic/Reuters)

IN EARLY 2014, the Obama administration stood by as the Islamic State began to expand from eastern Syria to Iraq. It watched as the terrorists seized control of city after city, including Mosul, fortified by thousands of foreign volunteers. By the time U.S. airstrikes finally were launched to prevent Iraqi Kurdistan from falling, the Islamic State had enough territory, economic resources and military equipment to consolidate a formidable base. Despite 18 months of U.S. bombing, it still stands.

Now something similar is happening in Libya. Libyan militants allied with the Islamic State control Sirte, the home town of late dictator Moammar Gaddafi, which lies between the capital, Tripoli, and Benghazi. At the direction of Islamic State authorities in Syria, foreign recruits are headed to Sirte, where they can build up a new “emirate” without being attacked by Western forces. The Pentagon says there are now more than 5,000 fighters in Sirte and that they control nearly 200 miles of Libya’s coastline. They have been attacking Libya’s oil infrastructure, and they aspire to launch attacks on Europe.

President Obama’s senior national security aides have been telling him, sometimes in public, that military action is urgently needed to stop the consolidation of a powerful new terrorist base. “It’s fair to say that we’re looking to take decisive military action,” said Gen. Joseph F. Dunford Jr., the chairman of the Joint Chiefs of Staff. Yet the White House is again waffling: A meeting to consider options late last month ended without decisions. The hesi­ta­tion risks a repeat of the Iraq debacle.

The principal reason for delay cited by administration officials is a wish to forge a new government in Libya prior to any military intervention. A U.N. mediator has been trying to coax the rival governments in the west and east to endorse a “unity” cabinet, which would then seek to patch together a national army to take on the jihadists. Western governments have discussed plans for a force, perhaps led by Italy, to protect the new regime, while trainers work with the army. Sirte, meanwhile, could be targeted with airstrikes.

The problem has been resistance to the new government from both sides — and in particular from supporters of Gen. Khalifa Haftar, a polarizing would-be strongman who commands forces in the east and has the backing of the repressive ruler of Egypt, Abdel Fatah al-Sissi. The general’s exclusion from the cabinet caused the eastern parliament to vote it down last month, though another vote is expected in the coming days. While approval would be a step toward re-creating the Libyan state, the process will necessarily be a long one at best. In the meantime, Islamic State forces are building up.

Ultimately, a Libyan political solution should not be a prerequisite for action against the terrorist threat. On Tuesday, Mr. Obama acknowledged the problems in forming a government and added that “as we see opportunities to prevent [the Islamic State] from digging in in Libya, we [will] take them.” Those opportunities exist now: The United States and its allies could conduct airstrikes against Sirte and help a Libyan protection force that has been trying to guard oil facilities. Mr. Obama has tried waiting on the sidelines in Iraq and Syria. He should not make the same mistake in Libya.