Mr. Trump said Keith Kellogg, another retired lieutenant general, would remain as the council’s chief of staff. Mr. Kellogg has been acting national security adviser since Mr. Flynn’s resignation a week ago and was one of the four candidates interviewed by Mr. Trump on Sunday for the permanent job. Mr. Trump made no mention of K. T. McFarland, the top deputy national security adviser, and whether she would stay.

General McMaster thanked Mr. Trump but gave no insight into his plans. “I’m grateful to you for that opportunity,” he told the president, “and I look forward to joining the national security team and doing everything that I can to advance and protect the interests of the American people.”

The other finalist was John R. Bolton, a former ambassador to the United Nations under Mr. Bush. This was the second time Mr. Bolton, an outspoken conservative, had been considered for a high-level post in Mr. Trump’s administration. Mr. Trump praised Mr. Bolton on Monday and said he would find a position for him.

“We had some really good meetings with him. Knows a lot,” the president said. “He had a good number of ideas that I must tell you I agree very much with. So we’ll be talking with John Bolton in a different capacity.”

General McMaster has served as director of the Army Capabilities Integration Center at Fort Eustis in Virginia since 2014. A West Point graduate with a doctorate in military history from the University of North Carolina at Chapel Hill, he commanded a unit that clashed with Iraq’s Republican Guard in one of the biggest tank battles of the Persian Gulf war in 1991, earning him the Silver Star.

But he came to prominence with his 1997 book, “Dereliction of Duty,” which critiqued the Joint Chiefs for not standing up to President Lyndon B. Johnson during the Vietnam War. He cemented his reputation in 2005 during the second Iraq war when he led the Third Armored Cavalry Regiment in regaining control of Tal Afar.

The operation was cited as a textbook example in a manual on counterinsurgency doctrine prepared by General Petraeus. Another commander who had a role in drafting that manual was Mr. Mattis, then a Marine general. General Petraeus took a similar approach when he assumed command in Iraq in 2007 with a surge of troops authorized by Mr. Bush.