THE 22 national security advisers who served Donald Trump’s predecessors included two army or marine generals. On February 20th Mr Trump equalled that tally in less than a month, by appointing Lieutenant-General H.R. McMaster to succeed the disgraced Mike Flynn.

Like the belligerent Mr Flynn, whom Mr Trump sacked after 24 days in the job, after it was revealed that he had lied about a private conversation with a Russian diplomat, General McMaster appears to conform to the president’s idea of a fire-breathing war-fighter. He is stocky, bullishly charismatic and as a tank commander in the first Iraq war was decorated for battlefield prowess. After bumping into an Iraqi armoured column, General McMaster’s troop of nine American tanks destroyed over 80 Iraqi tanks and other vehicles without suffering a loss.

Also like Mr Flynn, who was once an innovative intelligence officer, General McMaster is a freethinker. His doctoral thesis in military history was a ruthless takedown of the pliant Vietnam-era military leadership, later published as a book entitled “Dereliction of Duty”. Yet there the comparison ends. By the time of his appointment, Mr Flynn was known as a bad manager, obsessed with jihadism and so feverishly partisan that he represented a threat to the treasured neutrality of the armed forces. General McMaster is hugely respected by his peers, among whom he is considered one of America’s most thoughtful soldiers.

He is perhaps best known for his exploits in the second Iraq war. Deployed in 2005 to the northern city of Tal Afar, in command of a cavalry regiment, he showed it was possible, at least temporarily, to pacify even the most violent and baffling parts of the country. By the time General McMaster arrived there, the city had been overrun by insurgents and retaken bloodily by the Americans, but with too few American or Iraqi troops to control it.

Acting largely on his own initiative, he proceeded to put in place a model counter-insurgency regime. He ensured his officers studied Islamic culture, which at that time few American soldiers did, used force selectively and sparingly, and took pains to understand and work with the grain of Afari ethnic politics. He was lionised by American journalists, who, it is true, tend to lose their hearts to any successful battlefield commander; Tal Afar, now the scene of a fierce battle between the Iraqi army and Islamic State, did not stay quiet for long. Yet in his hunger to listen and learn—from Iraqis, his soldiers and even visiting journalists—General McMaster stood out.

His subsequent career has if anything been more distinguished. Championed by another charismatic counter-insurgency specialist, General David Petraeus, who was also considered by Mr Trump for the vacant national security post, but in effect ruled himself out of contention by insisting he be allowed to pick his staff, General McMaster helped run operations for the NATO mission in Afghanistan, after it was reinforced by Barack Obama in 2010. More recently, as head of the Army Capabilities Integration Centre, based in Fort Eustis, Virginia, he has led an effort to design and prepare the future American force that will emerge from the two wars in which he made his name. He has received fresh plaudits in that role; David Barno, a former American commander in Afghanistan, called him perhaps “the 21st-century army’s pre-eminent warrior-thinker”.

This does not mean General McMaster will be a good national security adviser, a perniciously difficult job, at which only a few have excelled. And they—led by Brent Scowcroft, who advised Gerald Ford and George H.W. Bush, and Stephen Hadley, who steered George W. Bush—tended to be known for tact and scrupulous impartiality. General McMaster is better known as a straight talker and a risk-taker, albeit by the conformist standards of his profession. Mr Trump, who is as prickly and ill-informed about global affairs as he is admiring of generals, may not find him easy to work with. Indeed, General McMaster is so different from Mr Flynn it is tempting to wonder on what criteria Mr Trump appoints his national security advisers. Even so, at the second attempt, he has picked well.

This also points to the biggest puzzle about the 45th president. Mr Trump has surrounded himself with amateurish and ideological advisers, led by Stephen Bannon, who have been responsible for much of the administration’s early haplessness. He has also hired some sensible and accomplished cabinet secretaries, such as James Mattis, the defence secretary, and, based on early reports, Rex Tillerson, the secretary of state. This group is believed to be opposed to, and possibly contemptuous of, Mr Bannon’s agenda—and General McMaster looks like a fine addition to it. So whose advice will Mr Trump follow? The answer is unclear. Yet the stability of the world may depend on it.