The stifling heat of the tarmac beneath the wings of his C-17 aircraft, the dragon’s breath backwash from nearby helicopters, and the unmistakable, acrid smell of summertime Baghdad must have brought back distant memories when Secretary of Defense Jim Mattis touched down there earlier this week. Like many of his peers, Mattis, a retired Marine Corps general, came of age as a field commander in the Afghan and Iraq wars, earning his nickname of “Mad Dog” as the commander of 1st Marine Division during the 2003 invasion, and in the subsequent fierce battles for Fallujah. A keen student of history, he popularized the division’s motto “no better friend, no worse enemy,” paraphrasing a maxim attributed to Roman general Lucius Cornelius Sulla.

All these years later, Mattis was returning to Iraq at a hopeful moment, with U.S.-backed Iraqi forces having recently recaptured the city of Mosul from the Islamic State after months of bloody urban fighting. Just the night before his arrival in Baghdad, President Donald Trump had also announced additional U.S. forces for the Afghan war and a new strategy formulated by Mattis, National Security Adviser and Army Lt. Gen. H.R. McMaster, and General Joseph Dunford, chairman of the joint chiefs. Trump’s tight circle of generals, which includes John Kelly, the White House chief of staff and a retired Marine four-star general, aims to reclaim an inheritance that the U.S. military fought and bled for, which the generals believe was nearly squandered in the waning years of the Obama administration.

The return to Iraq and the events of the past week marked an inflection point for Mattis, the first former general to serve as a secretary of defense since General George C. Marshall 70 years ago. Speaking to reporters in Baghdad on August 22, Mattis praised the leadership of Haider al Abadi, the prime minster of Iraq, and his security forces. “Cities have been liberated, people freed from ISIS … The economy is recovering. Clearly, Iraq is reengaging with the region, and ISIS is on the run.”

For Trump’s generals, what’s also notable is who is no longer inside Trump’s inner circle. Just before leaving for the Middle East, Mattis and the rest of Trump’s national-security team gathered at Camp David to finalize the new Afghan war strategy. Notably absent from the meeting was just-fired White House chief strategist Stephen Bannon, the populist provocateur who had fought bitterly and, increasingly, publicly with McMaster over the way forward in Afghanistan. Kelly, reportedly, all but ushered Bannon out the White House door. In the struggle for the soul of the Trump administration’s foreign and national security policies, Bannon’s ouster was a seminal moment. His hyper-nationalism and anti-globalist ideology is the antithesis of their worldview: By training, education, and hard experience, they are pragmatic realists and internationalists.

And yet: Just as Mattis sought to reassure nervous allies, back home there were numerous reminders that the populist and intemperate impulses of his boss will not be tamed. After Trump’s disastrous response to the violent protests in Charlottesville, in which he equated neo-Nazis, Ku Klux Klansmen, and white supremacists, with the counter-protesters who opposed them, Trump gave a disciplined speech on Monday unveiling the new Afghan strategy before uniformed service members at Fort Meyer, Virginia. Reading from a teleprompter, he cited U.S. troops as the “inspiration our country needs to unify, to heal.” Then, the very next day in a campaign-like rally in Phoenix, a bellicose and ad-libbing Trump was once again hammering the “us versus them” themes that propelled him to the presidency.

In another divisive move, the White House will reportedly soon issue guidance to the Pentagon barring transgender persons from serving in the military, a ban that Trump initially unveiled weeks ago in a surprise tweet that reportedly caught Mattis by surprise and left him “appalled.” That tension was evident throughout the week, as Mattis travelled to Iraq, Jordan, Turkey, and Ukraine.

In many ways, Mattis’s return to Iraq was a triumph. The conventional wisdom among senior U.S. military leaders has long been that the Obama administration’s decision to withdraw all U.S. troops from the country in 2011 was a strategic mistake. After ISIS overran roughly a third of both Syria and Iraq in 2014, President Obama essentially conceded the point, returning U.S. military forces to the country that summer, and beginning operations against the group in Syria.

5. Mattis: "Our country right now..it's got problems we don't have in the military." — Kevin Baron (@DefenseBaron) August 25, 2017

U.S. commanders had chafed, however, at the Obama administration’s sensitivity to the number of U.S. “boots on the ground,” and restrictive rules of engagement that required White House approval for many lethal strikes. Mattis thus moved to accelerate the anti-ISIS campaign, deploying more forces, and, with Trump’s approval, pushing the authority to launch lethal strikes down to U.S. field commanders.

To limit the ability of ISIS fighters to retreat and regroup, and for foreign fighters to slip through the coalition dragnet and return to their home countries and launch terrorist attacks, Mattis also developed an “annihilation strategy”: Rather than allowing ISIS fighters to flee from one battle to the next, the strategy calls for coalition forces to first encircle ISIS strongholds such as Mosul and Raqqa before starting operations to recapture them. U.S. military officials credit the strategy for limiting the number of ISIS fighters able to escape and live to terrorize another day. Mattis also did some damage control, asking Kurdish leaders to postpone a scheduled independence referendum.

On his trip, Mattis also suggested that the United States might leave a residual U.S. military force in Iraq for the foreseeable future, living up to the spirit of the Strategic Framework Agreement, a 2008 partnership first signed by President George W. Bush and his Iraqi counterpart. “[We] will continue standing by the Iraqi people and their military…to maintain the stability that has been earned at a very, very high price.”

The fight against ISIS has both unified Iraq and solidified the partnership between Washington and Baghdad, Jon Alterman, the director of the Middle East Program at the Center for Strategic and International Studies, told me from Iraq, where he arrived just after Mattis’s visit. “To the extent that the Iraqis were concerned that the United States would abandon them again, Mattis and Trump’s other generals all send the opposite message. They all have an intimate familiarity with Iraq, they know exactly where it is on a map, and they are looking for ways to leverage the costs and sacrifices the United States has already made here.”

Mattis’s warrior pedigree and reputation also calmed nerves in Jordan, where this week for the first time as defense secretary he met with King Abdullah II, a staunch U.S. ally. Like the other Sunni-Arab regimes in the Middle East, Jordan’s was concerned by the Obama administration’s opening to Iran through the nuclear deal, and the perception that America no longer strongly opposed its destabilizing role in the region. By contrast, then-General Mattis had been eased out by the Obama administration as head of U.S. Central Command because of his harsh rhetoric about Iran.

Where Iran is concerned, Mattis is now unmuzzled. In a rare recent interview with The Islander, the newspaper of Mercer Island High School, he described the Iranian regime as “acting more like a revolutionary cause.” This is a government that attempted to murder the Saudi ambassador to Washington, and employs surrogates like Lebanese Hezbollah that continues to threaten Israel and kill Israeli tourists, he noted. It has also supplied ballistic and anti-ship missiles to Houthi rebels in Yemen who have used them to attack Saudi Arabia and international shipping; at home, it continues to imprison many young Iranians, Mattis said. Iran is also “the only reason” Syrian President Bashar al Assad remains in power, he said. “So Iran is certainly the most destabilizing influence in the Middle East.”

Yet even on the territory of a staunch ally like Jordan, there was an element of damage control to Mattis’s visit. Shortly after Trump’s trip to nearby Saudi Arabia in May, where he bonded with Saudi royals and the other gulf monarchs, Riyadh and the other members of the Gulf Cooperation Council announced a blockade of Qatar, home to a major U.S. military base, over its alleged financing of terrorism. Trump has publicly backed the Saudis, working at cross purposes with Mattis and Secretary of State Rex Tillerson, who have sought to diffuse the crisis.

The next leg of Mattis’s trip offered a stark reminder of just how far west the shadow of authoritarianism has crept in recent years. In Ankara on August 23rd, he met with Recep Tayyip Erdogan, the president of Turkey, and his foreign-affairs and national-security team. As Mattis told reporters, Turkey is a “frontline state against terrorists right there in Syria…[and] a frontline state on dealing with refugees, who are traumatized as any you’ll ever find in the history of the world.”

In recent months, senior U.S. military officials have continually stressed to Turkey that Washington’s decision to arm and train Kurdish-led Syrian Democratic Forces (SDF) has been narrowly focused on enabling them to recapture Raqqa from ISIS. The United States has also helped the Turkish military rebuild after its recent operations in northern Syria. The U.S. intelligence community continues to share intelligence with Ankara about the Kurdish terrorist group PKK, which seeks an independent Kurdish state in southeastern Turkey, and has waged a deadly, decades-long terrorist campaign in Turkey.

“We have done everything we can to address Turkish concerns, and I personally have made on the order of nine visits to Turkey to speak with my counterpart there,” General Joseph Dunford, chairman of the Joint Chiefs of Staff, told me. “The Turks have indicated publicly that they don’t like the fact that we armed the [largely Kurdish] Syrian Democratic Forces, so this issue has been a challenge and an irritant in U.S.-Turkish relations, there is no doubt about that.”

There is also no doubt that when Mattis, Dunford, and other senior U.S. officials visit Turkey these days, they no longer encounter the reliable NATO ally and Muslim democracy that the United States once held up as a model for the Islamic world. Erdogan has publicly blamed Washington for seeking to unseat him in last year’s failed coup; he has also consolidated power, brutally suppressing political opposition to his Islamist agenda by arresting tens of thousands of academics, government officials, journalists, secularists, and members of non-governmental organizations. Turkey still allows the U.S. military to use Incirlik air base for its anti-ISIS campaign, but increasingly its relations with the United States and other NATO allies are transactional, no longer based on shared values such as democracy and human rights.

“In his meeting with Mattis, Erdogan continued to criticize U.S. support for the Syrian Kurds, but the bigger issue is this systematic smear campaign that the Turkish government and government-controlled media have kept up against the United States and NATO countries,” Aykan Erdemir, a former member of the Turkish parliament and a senior fellow at the Washington-based Foundation for the Defense of Democracies, told me. “The United States is not only in danger of losing the Erdogan government as a reliable ally, but it is also starting to lose the hearts and minds of 80 million Turks who are increasingly skeptical of the West.” Indeed: 72 percent of respondents in a recent opinion poll viewed the United States as the country’s top security threat.

To conclude his tour of world crises, Mattis stopped in Kiev on Ukraine’s Independence Day. The optics of his visit drove home just how profoundly constant controversies, major personnel upheavals, and the rise of Trump’s generals have altered the trajectory of his administration. Last summer at the Republican National Convention, with Trump constantly praising Vladimir Putin and his inner circle reaching out to the Russians, his campaign quietly managed to remove a plank calling for U.S. support of Ukraine with lethal weaponry from the party platform. Since then, multiple investigations have been launched into Russia’s meddling in the election and the Trump campaign’s possible collusion in those efforts, and Congress has passed veto-proof legislation ensuring that the White House cannot relax sanctions put in place after Russia annexed Crimea and supported separatist rebels in eastern Ukraine.

In Kiev on Thursday, Mattis signaled that, while no decision had yet been made on whether the U.S. will provide Ukraine with defensive weapons, he personally supports the move. “I will go back now having seen the current situation and be able to inform the secretary of state and the president in very specific terms what I recommend for the direction ahead,” Mattis told reporters in Kiev, standing alongside Ukrainian President Petro Poroshenko. “Defensive weapons are not provocative unless you are an aggressor, and clearly Ukraine is not an aggressor since it is their own territory where the fighting is happening.”

Of course more weapons in the region could also escalate the conflict by emboldening Poroshenko and challenging Putin’s strongman image. A similar dynamic in Georgia in 2008 led to a Russian invasion and de facto annexation of two Georgian provinces.

“If we escalate in Ukraine when Putin is facing upcoming elections and more dependent than ever on his tough guy credentials, it could easily change Moscow’s calculus in a dangerous way,” Dmitri Simes, a Russia expert and president of the Washington-based Center for the National Interest, told me. The more diplomatic path would be for the United States to pressure both Ukraine and Russia to honor the Minsk Agreement that was supposed to end the conflict, he said. But with the Trump administration under investigation for potentially secret ties to Russia, Congress would likely oppose any pressure on Ukraine.

Simes also worries that, with generals so ascendant in the Trump administration, military solutions will naturally begin to take precedence over diplomatic ones. “I hear only good things about Mattis, and generals are important in terms of reassuring our allies and providing sound military strategies and advice to the president,” Simes said. “But there is a long American tradition of having civilians with strong national security credentials in these jobs, and for a good reason. As the old saying goes, war is too important to be left to the generals.”

In a week that included a new strategy for the Afghan war, a triumphant return to Iraq, and a tour of global hotspots, Mattis attempted to both reclaim the legacy of the U.S. military’s longest wars and mitigate the damage done to U.S. alliances by the administration’s “America First” foreign policy. The challenge for him and Trump’s other generals is that the epicenter of the growing instability and uncertainty they encounter overseas is increasingly the White House itself.