The American flag is lowered to half-staff above the White House on July 21 to honor the five U.S. service members who were killed by a gunman in Chattanooga, Tenn., last week. (Andrew Harnik/AP)

President Obama, facing growing criticism from conservatives and some veterans, ordered all American flags on federal grounds to be lowered to half-staff for the remainder of the week to honor the five service members killed at a naval reserve center in Chattanooga, Tenn.

The move was announced Tuesday, five days after the shooting rampage and just minutes after Obama delivered a speech here at the Veterans of Foreign Wars convention in which he defended his Iran nuclear deal, called for more military spending, and criticized Republicans for relying too heavily on military force and threats instead of diplomacy.

Standing before a crowded hall of aging veterans, Obama eulogized each of the four Marines and the one sailor killed by a gunman in Chattanooga. Tom Sullivan was “everything that a Marine should be,” Obama said. Skip Wells was so devoted to the Marine Corps that he wore his dress blues to his home town’s Fourth of July parade. David Wyatt led with courage in Afghanistan and mentored comrades with post-traumatic stress disorder. Carson Holmquist loved his wife, Jasmine, and their 2-year-old son. Randall Smith, the sailor, was a high school baseball star with two young daughters he called “little princesses.”

But even as he spoke, the president faced stinging criticism that he hadn’t acted swiftly enough to honor the dead by lowering the flag at the White House and federal buildings around the country.

“Oh one more thing, lower the FLAG!!!!!!!! Sir,” former Navy SEAL Marcus Luttrell, author of the best-selling book “Lone Survivor,” wrote on his Facebook page.

That critique was then echoed on Capitol Hill, where House Speaker John A. Boehner (R-Ohio) and Senate Majority Leader Mitch McConnell (R-Ky.) moved quickly to lower the flag to half-staff on the Capitol grounds.

The midsummer tempest highlighted how Obama — six years into his tenure as commander in chief — continues to be pressed to defend his patriotism, his support for the military and his toughness.

Those questions have grown especially pointed in the wake of the agreement with Iran to limit its nuclear program. Republican critics of the deal have blasted it as too weak and conciliatory, and insisted that tougher sanctions and threats of force would have been more effective in bending Iranian will.

In his VFW speech, Obama fired back, saying his more measured and diplomatic approach had produced results. “Instead of chest-beating that rejects even the idea of talking to our adversaries — which sometimes sounds good in sound bites, but accomplishes nothing — we’re seeing that strong and principled diplomacy can give hope of actually resolving a problem peacefully,” he said.

Obama also sought to demonstrate his toughness. In one of the speech’s most striking moments, he said he would not hesitate to use force against those who threatened the United States, and then he read a list of al-Qaeda leaders killed on his watch.

“Osama bin Laden is gone,” Obama said. “Anwar Awlaki, a leader of the al-Qaeda affiliate in Yemen, gone. Many of al-Qaeda’s deputies and their replacements, gone. Ahmed Abdi Godane, the leader of the al-Qaeda affiliate in Somalia, gone. . . . The list goes on. If you target Americans, you will have no safe haven.”

The VFW crowd applauded heartily for that list, but the reception overall was cool, if respectful.

Obama also struck a hawkish pose in blasting Republicans for backing automatic cuts — known as sequestration — that would pare back defense spending. He accused the Republicans of “trying to fund our military with gimmicks” that would “shortchange national security programs like counterterrorism” and “increase risk to our troops.”

“I’ve got a better idea, which is to end sequestration, increase the defense budget, invest in America’s strengths,” Obama said. “We shouldn’t be playing partisan politics when it comes to national security.”

“These mindless cuts have to end,” he said.

Obama vowed to veto any “bill that locks in” the automatic cuts. That sets up a clash with Republicans who have pressed for more defense spending — without the matching increases to domestic programs that Democrats are demanding. Republicans believe those domestic spending hikes are too costly.

On the issue of lowering the flags, Obama seemed to hear the mounting Republican criticism and respond to it. There are no clear or consistent rules that apply to lowering flags to half-staff. Obama ordered flags lowered after the mass shooting at Fort Hood in 2009 but didn’t lower them when a gunman struck last year at the Army post in Texas.

He has lowered flags almost immediately after mass shootings in Tucson; Aurora, Colo.; Newtown, Conn.; Oak Creek, Wis.; and the Washington Navy Yard.

He has ordered flags to half-staff after the deaths of American icons such as Neil Armstrong, Edward M. Kennedy, Dorothy Height and Frank Buckles, the nation’s last surviving World War I veteran.

But he didn’t lower the flag after last month’s shooting in Charleston, S.C.

Obama focused most of Tuesday’s VFW speech on defending his foreign policy record and detailing improvements made to the Department of Veterans Affairs after last year’s scandal in which VA officials were found to have falsified records to cover up the long waits that many veterans faced to get basic medical care.

VA is now handling millions more appointments, and waiting times for veterans have fallen, Obama said. But he also acknowledged that VA continues to struggle with a surge of aging veterans as well as younger veterans of the long wars in Iraq and Afghanistan.

“You put it all together, and in some places, wait times are higher than they were last year,” he said.

The best way to honor all veterans, Obama said, was through a foreign policy that focused first on diplomacy and turned to war only as a last resort.

“I’m hearing echoes of some of the same policies and mind-set that failed us in the past,” Obama said. He said the critics of the Iran deal include “some of the same folks who were so quick to go to war in Iraq . . . [who] said it would only take a few months.”

Although Obama did not mention former president George W. Bush, Obama said past administrations were guilty of “rushing into war without thinking through the consequences.”

“Who paid the price?” Obama asked. “Our men and women in uniform.”