Secretary of Defense Jim Mattis lost the person who helped him check President Donald Trump’s worst foreign policy impulses when Trump fired Secretary of State Rex Tillerson on Tuesday.

During Trump’s first 14 months in office, Mattis and Tillerson formed a united front to push back against the president on key national security issues. They ensured Trump didn’t “totally destroy” North Korea, they persuaded him to stay in the Iran deal (for now), and they convinced him that supporting NATO was better than not.

However, experts say, this change could actually work to Mattis’s advantage.

One reason is that Tillerson never connected with Trump, so Mattis had to do much of the heavy lifting to convince the president and other administration officials to see things their way. But Trump’s choice to replace Tillerson, current CIA Director Mike Pompeo, could prove a valuable ally for Mattis for one simple reason that sounds a little counterintuitive: He’s a Trump loyalist.

“Pompeo has the president’s ear and the president’s confidence,” Christine Wormuth, the Pentagon’s top policy official from 2014 to 2016, told me. “In the cases where Mattis and Pompeo agree, I think it could actually be better in terms of their ability to shape the president’s views.”

And Mattis on Thursday lost another person who helped check the president: former National Security Adviser H.R. McMaster. Trump let McMaster go and replaced him with former US Ambassador John Bolton. McMaster will retire from the military.

But if Mattis forms a bond with Pompeo, the defense secretary’s advice — which Trump already highly respects — might carry even more weight with him.

There’s a potential (large) hiccup, though: Pompeo sides with Trump on several major foreign policy issues; he believes the US should end the Iran deal and act forcefully against North Korea.

“If Pompeo chooses to be a constraining influence against Trump, he could potentially be a Mattis ally,” Tom Wright, a foreign policy expert at the Brookings Institution think tank, told me. “But if he can’t speak truth to power, or doesn’t push back on Trump, then he could be a big problem.”

The secretary of defense valued Tillerson’s opinion. Trump didn’t.

During his farewell statement on Tuesday, Tillerson bragged about the close partnership between the Pentagon and Foggy Bottom: “I’m told for the first time in most people’s memory, the Department of State and Department of Defense have a close working relationship where we all agree that US leadership starts with diplomacy.”

(Experts tell me that’s not entirely true. For example, former Defense Secretary Robert Gates and former Secretary of State Hillary Clinton famously worked well together at the start of the Obama administration.)

But Tillerson’s choice to highlight the partnership spoke volumes. Over the course of their year together, Mattis and Tillerson bonded, in part because they frequently discussed thorny foreign policy problems. They often formed a united front when presenting policy positions to the president or other key staff.

“We’re operating with very much a depth to our State Department — not outside the State Department’s foreign policy, but inside it,” Mattis said during a January 19 speech unveiling the new National Security Strategy. “[I]t starts with me having breakfast every week with Secretary of State Tillerson. And we talk two, three times a day, sometimes. We settle all of our issues between he and I, and then we walk together into the White House meetings. That way, State and Defense are together.”

They even publicly laid out their joint strategic thinking for how to deal with Pyongyang in a Wall Street Journal op-ed last August, noting that “diplomacy is our preferred means of changing North Korea’s course of action, [but] it is backed by military options.” When asked by reporters about issues ranging from Syria to Afghanistan to North Korea, Mattis typically reiterates that diplomats lead America’s foreign policy efforts.

But no matter how much Mattis and Tillerson coordinated, Trump found a way to consistently — and publicly — break with his secretary of state.

Last June, Trump slammed Qatar as a state sponsor of terrorism just one hour after Tillerson defended the country. Three months later, Tillerson told reporters at the United Nations that Trump was “still considering” whether to decertify Iran’s compliance with the nuclear deal. But a few hours earlier, Trump told reporters that he had made up his mind on the matter.

And in December 2017, Trump rebuffed Tillerson’s effort to open a diplomatic channel with North Korea. As if to turn the knife, Trump then kept Tillerson out of the loop while he accepted a high-stakes meeting with North Korean leader Kim Jong Un.

Mattis, meanwhile, remains in good standing. Trump praised Mattis during his State of the Union address in January, saying he was “doing a good job.” Clearly, Mattis’s advice to Trump and other officials — which, again, he coordinated with Tillerson — didn’t tarnish the defense secretary’s reputation. In effect, Mattis didn’t really need Tillerson to get his points across.

“Even if Tillerson and Mattis agreed on everything, Tillerson’s ability to persuade the president wasn’t high,” Wormuth, who is now at the Atlantic Council, told me. “It’s unclear just how much Tillerson added to their partnership.”

An unnamed Republican went so far as to tell Politico on Tuesday that Tillerson’s need for Mattis’s backing was like “a drowning man clinging to a life raft.”

When I asked Pentagon spokesperson Dana White if Tillerson’s ouster would leave Mattis more isolated when presenting advice to the president, she simply replied, “No.”

The question, then, is if Pompeo will prove an anchor or a buoy to Mattis — a policy ally or a policy foe. The jury’s still out on that.

Mattis’s success may now be tied to Pompeo

If Pompeo becomes the next secretary of state, Trump will have someone in that role he didn’t have with Tillerson: a like-minded person.

Here are just some examples: Pompeo repeatedly misrepresented the intelligence community’s January 2017 assessment that Russia tried to help Trump win the 2016 presidential election, saying the report shows Moscow had no effect on the vote’s final result.

Pompeo has also said he wants to end the Iran deal, a 2015 agreement between the US, Iran, and European and Asian powers that lifted a series of punishing economic sanctions in exchange for Tehran accepting strict curbs on its nuclear-related activities — just like Trump.

He sees the threat from terrorist groups such as ISIS and al-Qaeda as a top national security threat, and criticized the Obama administration for its refusal to call it “radical Islamic terrorism” — also like Trump. And he consistently defends the president’s forceful stance against North Korea, saying on Sunday that the US will make “no concessions” to Pyongyang even as a potential Trump-Kim summit looms.

Most crucially, Pompeo quickly developed a close relationship with the president while serving as CIA director. He gave Trump daily intelligence briefings as well as his thoughts on whatever political or national security issue might be prominent that week.

It’s completely possible, experts say, that Pompeo could continue to hew closely to Trump in his new role. But interestingly, experts say it’s likelier that Pompeo falls in line with Mattis.

“I think he will adapt carefully to his new position and won’t be brash even though he has some strongly held views,” Lincoln Bloomfield, who led the State Department’s political-military affairs bureau from 2001 to 2005, told me. “There’s no reason Mattis and Pompeo can’t have a good relationship,” he added. “I’d expect them to.”

And if that happens, Mattis might find even more success reeling in Trump because he will have a strong, Trump-endorsed ally.

Mattis and Pompeo, however, haven’t worked together much in the administration, except on the Afghanistan strategy review that paved the way for the US to send thousands more troops to Central Asia. That means they will have to find a way to coexist. Mattis has already demonstrated his willingness to cooperate closely with a secretary of state.

But will Pompeo show the same eagerness to work with his Pentagon counterpart?

“Pompeo has been auditioning for this job for a year, and now he has it,” Wright, the Brookings scholar, told me. “Will that change him in any way? Because now it’s about how he wants to be remembered, and if he believes Trump’s preferences result in better policy.”

Mattis will surely want to know that too — and soon.

Update 3/15/18: This article has been updated to reflect the exact exchange between myself and Dana White.