President Obama on Tuesday defended a pair of U.S. commando raids in Libya and Somalia, arguing that the ongoing targeting of alleged terrorists did not amount to an extended, perpetual war.

Obama’s remarks came in response to a question about whether the separate raids in Northern and Eastern Africa over the weekend represented an expansion of U.S. anti-terror efforts and broke his campaign promise to end a decade of foreign wars.

“There is a difference between us going after terrorists who are plotting directly to do damage to the United States and us being involved in wars,” he said during a press conference Tuesday dominated by questions about Obama's budget standoff with Republicans and the government shutdown.

Obama said the attack was consistent with U.S. policy to target those who were plotting against American citizens.

“Where you've got active plots and active networks, we're going to go after them,” the president vowed.

The president said the U.S. also needs to engage in a “war of ideas” in the region and operate a long-term broad foreign policy that is not “just military-based.”

“We've got to think about economic development because although there's not a direct correlation between terrorism and the economy, there is no doubt that if you've got a lot of unemployed, uneducated young men in societies, that there is a greater likelihood that terrorist recruits are available,” he said.

Obama also said that “we prefer partnering with countries” where terrorists are operating, but pledged not to “farm out our defense.”

In Libya, Abu Anas al-Libi, a top al Qaeda operative accused by Washington of involvement in the 1998 bombings of U.S. embassies in Kenya and Tanzania, was ambushed and captured on a street in Tripoli in an operation Saturday.

In the second raid, a U.S. Navy SEAL team swam ashore at a seaside villa south of Somalia's capital, Mogadishu, and engaged in an intense firefight with al Shabbab militants. The target of the U.S. raid is believed to have been senior al Shabbab leader Abdikadir Mohamed Abdikadir, alias Ikrima.

The SEALs later withdrew from the fighting, and it's unclear whether Ikrima was killed.

Obama lauded this weekend's military operations, saying the unselfish bravery and sacrifice involved should serve as an example to Washington.

The operations, he said, are "examples of the extraordinary skill and dedication and talent of our men and women in the Armed Forces. They do their jobs extremely well, with great precision, at great risk to themselves. And I think there are pretty good examples for how those of us here in Washington should operate as well."