President Donald Trump’s new defense secretary, retired Marine Corps Gen. James Mattis, has said “it’s a hell of a lot of fun to shoot” Taliban fighters, told Iraqi leaders that “if you fuck with me, I’ll kill you all,” and accused the Obama administration of naiveté for inking a nuclear deal with Iran that will slow, but not stop, Tehran’s path to a bomb.

Don’t let those quotes — or Mattis’s nickname, “Mad Dog” — fool you. Despite his salty language, Mattis is a serious strategic thinker who is widely respected inside and outside of the Pentagon for his intellect and willingness to offer unvarnished assessments of White House strategy, despite the risks to his own career. The Senate overwhelmingly confirmed him as the nation’s new defense secretary just hours after Trump himself took the oath of office and moved into the White House.

One of Trump’s first acts in office was to sign a CongressIonal waiver allowing Mattis to serve in the post even though he only retired from the military a few years ago. Under current law, officers need to be out of uniform for at least seven years before they can be appointed to run the Pentagon. Mattis is likely to assume his new post almost immediately, putting a Russia hawk with harder-line views about Russian strongman Vladimir Putin than Trump has at the helm of the nation’s armed forces.

“I’m all for engagement, but we have to recognize reality,” the retired general said at his confirmation hearing earlier this month when asked about Putin’s Russia. “There are a decreasing number of areas where we can cooperate, and an increasing number of areas in which we will have to confront Russia.”

Mattis’s views about Iran are, if anything, even more hawkish than his views about Russia. A well-known figure among current and retired military officers, Mattis has spent years warning publicly and privately about the threat posed by Iran, and that may be the most important thing to understand about the incoming defense secretary. Donald Trump spent his campaign talking tough about Tehran and blasting the nuclear deal, but he’s offered few specifics about what he would actually do in office.

That means Mattis — a hawk who describes Tehran as “the single most enduring threat to stability and peace” in the Middle East — will be instrumental in shaping the new administration’s Iran policy. He’ll also help determine whether Trump chooses to one day use force against Tehran.

The next secretary of defense really, really hates Iran

Mattis commanded Marines in Iraq’s Anbar province in 2004, then held a variety of senior posts before spending 2010 to 2013 at the helm of the military’s Central Command, which oversaw the wars in Iraq and Afghanistan.

He came away from that job with a deeply held belief that Iran’s support for Shia militias in Iraq meant that Tehran was directly responsible for the deaths of hundreds of American troops — and that the Obama administration’s nuclear deal with Iran would help that country further expand its influence across the region.

The retired general gave a detailed description of his thinking about Iran during an April speech at the Center for Strategic and International Studies, a centrist Washington think tank.

Mattis told the crowd that he understood the administration’s rationale for striking its landmark nuclear deal with Tehran, and believed that it would successfully delay Iran’s push for a nuclear weapon. But Mattis said the White House had erred by not doing more to stop Iran from providing arms, money, and fighters to Syrian President Bashar al-Assad or shipping large quantities of weaponry into countries like Yemen.

In his comments at the think tank, Mattis said that Iran posed four specific threats to the US and its allies, apart from its nuclear program: its ongoing development of advanced ballistic missiles capable of one day hitting Israel and Europe; its stated threats to block vital international waterways like the Strait of Hormuz; its increasing cyber attack capabilities; and its support for armed proxies ranging from Hezbollah in Lebanon and Syria to the Houthis who now control Yemen.

Iran, he said, “remains the single most belligerent actor in the Middle East,” and one whose “consistent behavior from the 1979 through today shows no signs of changing.”

Mattis believes Iran’s support for Shia militias in Iraq meant that Tehran was directly responsible for the deaths of hundreds of American troops.

During his years running Central Command, Mattis shared similarly hawkish assessments about Iran with senior Obama administration officials. According to sources I spoke to at the time, many in the White House sharply disagreed with the general and felt there was a real chance at a diplomatic breakthrough on the nuclear front.

Things reached a breaking point in early 2013 when Obama abruptly removed Mattis from his post. According to the well-sourced military reporter Tom Ricks, the move came because senior administration officials grew tired of Mattis’s insistence that the Iranian threat extended well beyond its nuclear program:

Pentagon insiders say that he rubbed civilian officials the wrong way — not because he went all "mad dog," which is his public image, and the view at the White House, but rather because he pushed the civilians so hard on considering the second- and third-order consequences of military action against Iran. Some of those questions apparently were uncomfortable. Like, what do you do with Iran once the nuclear issue is resolved and it remains a foe? What do you do if Iran then develops conventional capabilities that could make it hazardous for U.S. Navy ships to operate in the Persian Gulf? He kept saying, "And then what?"

Now that he's been confirmed, Mattis will be working with a president who shares his hawkish views about Iran and is much more inclined to take a harder line with Tehran than the Obama administration was.

Neither Trump nor Mattis has explicitly called for using force against Iran, but that will be much likelier in a Trump White House than it had been in the Obama one. Mattis has wanted to confront the Iranians for years. He may get the chance.

Mattis sees Putin very differently than the new president does

Mattis is also a Russia hawk — a position that would potentially leave him at odds with the new president.

During the campaign, Trump repeatedly praised Russian strongman Vladimir Putin as a strong leader and took positions — including endorsing Moscow’s support for Assad in Syria and refusing to commit to defending NATO allies against a possible future Russian invasion — that are closely in line with the Russian leader’s long-held strategic goals. Putin, Trump said last December, is “highly respected within his own country and beyond.”

Mattis, echoing the assessments of most of the Pentagon’s top brass, has a sharply different assessment of Putin, whom he sees as a clear threat to both the US and many of Washington’s closest European allies.

According to an article by the US Naval Institute, Mattis used a speech to a conservative think tank last May to warn that Russia’s annexation of Crimea and continued meddling in eastern Ukraine was a “severe” and “serious” threat that was being underestimated by the Obama administration.

Putin, Mattis concluded, was trying to “break NATO apart.”

Trump has threatened to fire generals who disagree with him, and there’s no area where the Pentagon’s uniformed brass differ from the new president more vividly than on Russia. With Mattis running the Defense Department, those generals will now have one of the loudest defenders imaginable. Whether Mattis goes to bat for them, and how Trump responds, remains to be seen.

Trump has literally made history by choosing a retired general to run the Pentagon

Mattis, who spent three years overseeing the US wars in Iraq and Afghanistan, is the third retired general Trump has tapped for his administration, but there are several key differences between him and the more controversial of the two, new National Security Adviser Michael Flynn.

Mattis has never expressed anything resembling Flynn’s alarming anti-Muslim rhetoric or embrace of far-right conspiracy theories. During the campaign, Mattis also never joined the crowds of rabid Republican partisans calling for Hillary Clinton to be jailed.

Mattis disagrees with Trump on Putin, whom he sees as a clear threat to both the US and many of Washington’s closest European allies

Current law bars uniformed officers from running the Pentagon until they’ve been out of uniform for seven years, so Mattis, who retired in 2013, needed Congress to pass legislation waiving that rule, something lawmakers have only done once in the law’s 65-year history. (The law initially had a 10-year ban; in 2008, it was changed to a seven-year one.) That exception came in 1950, when Congress cleared the way for retired Army Gen. George Marshall to hold the position even though he had only left the military five years earlier. The language of the amended law said that after Marshall retired, “no additional appointments of military men to that office shall be approved.”

Mattis has his detractors, and even some who personally like and respect the retired general had questioned whether he was the right choice to run the Pentagon’s sprawling bureaucracy.

In a op-ed for War on the Rocks, a website popular in military and national security circles, counterinsurgency expert Erin Simpson argued that Mattis was a brilliant warrior who would have a tough time managing the mammoth Defense Department and working for a president as mercurial and resistant to expert advice as Trump:

Many in defense circles have been so overjoyed at the prospect of a qualified secretary, that they seemed to have forgotten to stop and ask if Mattis would, in fact, be right for the job. He is not a politician, or a wonk, or a bureaucrat. To ask him to be any of those things would be like trying to keep a wave upon the sand... The point is not that Mattis is unqualified. Rather, the point is that he hates this shit.

More substantively, Russia isn’t the only place where Mattis’s positions don’t quite line up with those of the president he’ll serve. He has rejected the use of waterboarding, a brutal interrogation technique Trump has talked about reinstating. In an interview with the New York Times last week, Trump suggested that Mattis had singlehandedly changed his mind:

“He said, ‘I’ve never found it to be useful,’” Mr. Trump said, describing the general’s view of torturing terror suspects. He added that Mr. Mattis found more value in building trust and rewarding cooperation with terror suspects: “‘Give me a pack of cigarettes and a couple of beers and I’ll do better.’” He added: “I was very impressed by that answer.’’

Mattis has also said it was a mistake for a US president to deride close allies as “freeloaders” because they didn’t spend more on their own defense. Trump has repeatedly done exactly that, complaining that nations like Japan and South Korea should build stronger militaries instead of relying on the US for protection.

Still, Trump had been signaling for weeks that Mattis was his man. With Friday’s vote, the new president has the defense secretary he has long wanted. There’s one thing Trump won’t be getting with Mattis, however: a rubber stamp.

Watch: How Trump thinks about foreign policy