WASHINGTON — At one point or another, they each strode the sands of Iraq, fighting on the unforgiving battlefield of America’s costliest war since Vietnam. Now all three will sit around the table in the White House Situation Room, steering a new president through the treacherous crosscurrents of a stormy world.

President Trump’s appointment of H. R. McMaster, an Army lieutenant general, as his new national security adviser creates a powerful troika of senior officers who served in Iraq, teaming him up with Defense Secretary Jim Mattis and John F. Kelly, the secretary of homeland security, both retired four-star Marine generals. This administration is the first to have all three security jobs filled by senior military veterans at the same time.

The ascension of the three generals to political jobs at the National Security Council reflects the rise of a generation of military leaders that came of age during the wars in Afghanistan and Iraq that began after the Sept. 11, 2001, attacks. Each officer saw up close what a losing war looked like and took away lessons about how to avoid repeating fatal mistakes. Each got to where he is today in part by bucking the military hierarchy.

“This generation of generals lived through some of the struggles, especially in the ’04, ’05, ’06 time frame in Iraq when we weren’t doing things right,” said Senator Tom Cotton, Republican of Arkansas, an Army veteran who served in Iraq. “They understand that security and military force are the pre-eminent requirement, but it’s not sufficient. This generation of generals who grew up in the Iraq war probably understands that more than any previous generation.”