President Obama on Wednesday defended his administration’s efforts to dismantle al-Qaeda, as a worldwide threat alert and the shuttering of embassies across the Middle East raised questions about the success of the U.S. fight against terrorism.

Obama came to a Marine Corps base here to salute service members for their central role in waging the U.S. wars in Iraq and Afghanistan, telling the nearly 3,000 Marines and their families that they should be proud of all they have achieved.

“Because of you, the 9/11 generation, we are accomplishing what we set out to do. Because of you, Osama bin Laden is no more,” Obama said to cheers. “Because of you, al-Qaeda’s top ranks have been hammered. The core of al-Qaeda, in Afghanistan and Pakistan, is on the way to defeat. That happened because of you.”

Since giving a landmark speech in May at the National Defense University in Washington, Obama has been working to make the case that al-Qaeda has been significantly diminished and that the United States can begin to plan for an era that is not defined so singularly by the battle against terrorism.

Yet those ambitions have been challenged in recent days with reports of a significant security threat that is said to emanate from al-Qaeda in the Arab Peninsula, the terrorist group’s affiliate in Yemen. The State Department has closed a dozen U.S. embassies in the Middle East and Africa and issued a worldwide travel alert in response to intelligence reports.

President Obama speaks with U.S. troops and their families at the Marine Corps Base in Camp Pendleton, Calif., on August 7. (Jacquelyn Martin/AP)

In his remarks here, Obama said he is well aware of the threats that continue to face the nation.

“Al-Qaeda affiliates and like-minded extremists still threaten our homeland. They still threaten our diplomatic facilities,” he said. “They still threaten our businesses abroad. And we have got to take these threats seriously, and do all we can to confront them.”

Obama used his appearance before service members to condemn sexual assault in the military, a problem that has been drawing increased attention and concern on Capitol Hill and nationwide.

“I want you to hear it directly from me, the commander in chief,” Obama said. “It undermines what this military stands for, and it undermines what the Marine Corps stands for when sexual assault takes place within our units. And that’s why we are going to work together — all of us — to stop these crimes of sexual assault, and uphold the honor and integrity that defines the finest military on Earth. And that message is coming all the way from the top.”

Camp Pendleton, located 40 miles north of San Diego, is home to the First Marine Expeditionary Force, which has operated extensively in Iraq and Afghanistan. Obama’s visit came at the end of a two-day West Coast swing focused on strengthening the nation’s housing market.

The president broke no new policy ground in his remarks. He said he looks forward to completing the U.S. withdrawal from Afghanistan, even though it will not be the end of the nation’s commitment there.

“Instead of leading the fight, our troops now have a different mission, which is to train and advise and assist Afghan forces,” Obama said. “More of our troops are coming home. We’ll be down to 34,000 this winter. By the end of next year, in just 17 months, the transition will be complete.”

He added, “But, what we cannot do is repeat the mistakes of history. We have seen in the past, where, after a war, we hollowed out our military, left our military unprepared.”

In that light, he said it makes no sense for the country to continue to slash domestic and defense spending under the automatic budget cuts known as sequestration. Obama would prefer to shrink the federal deficit by raising taxes on the wealthy rather than allow those cuts to continue.

“That is not how a great nation should be treating its military and military families,” he said. “And, by the way, cuts in other non-defense areas in the budget affect our troops and our military families as well. You know, our military — part of what makes us best is we have got extraordinary recruits. But, if we want the best-qualified recruits, we should not be cutting investments in education. We should be increasing our investment in education.”