President Donald Trump and John Bolton are currently disputing whether the former White House national security adviser resigned or was fired on Tuesday. The acrimonious squabble, which first percolated on Twitter, inevitably spilled onto the airwaves of Fox News, Bolton’s former employer. “John Bolton just texted me just now,” Fox host Brian Kilmeade interjected that afternoon on the panel show Outnumbered. “He’s watching, and he said, ‘Let’s be clear, I resigned.’”

It’s no coincidence that Bolton was watching his former colleagues and responding to them in real time. It’s impossible to disentangle virtually any aspect of his ill-fated White House tenure from Fox’s influence. The right-wing propaganda network was the key vector for both his hiring and his subsequent diminishment, and it may ultimately play a role in determining his replacement.

Fox hired Bolton as a contributor in 2007, shortly after he left his post as the Bush administration's United Nations ambassador. A noted hard-liner who had served in the previous two Republican administrations, Bolton was popular among conservatives. But his hawkishness and abrasive personality had rendered him toxic and made his confirmation by the U.S. Senate impossible.

Those attributes were apparently a plus for Fox, which made him the network’s face for national security policy over the next decade. In his regular appearances on the network, he portrayed President Barack Obama as a wimp who was unwilling to do the necessary work of bombing a lengthy list of countries, particularly Iran. Following Trump’s election, he lavishly praised the new president’s foreign policy speeches.

Bolton’s aggressive Fox appearances helped shape the worldview of its audience. And they caught the eye of one of the network’s most loyal viewers, Trump. In a 2015 interview, NBC’s Chuck Todd asked the then-presidential candidate who was advising him on national security. Trump responded by naming Bolton, who he described as “a tough cookie, knows what he’s talking about.”

After his election, Trump reportedly considered but ultimately passed on nominating Bolton for a top role in the State Department. But in March 2018, the president chose him to succeed H.R. McMaster as national security adviser. Trump made that decision, according to numerous reports, because he “had seen Bolton’s regular appearances on Fox News and relished the way he validated the administration’s policies,” as The Atlantic’s Peter Nicholas put it. He was one of numerous top officials to impress the president via their stints at the network. The appointment came with such haste that Bolton first learned that Fox no longer employed him while on air during a previously scheduled interview.

But Bolton’s influence began to wane almost immediately after he began advising the president in person, rather than through his television set. The two never developed a personal rapport, and Trump at times appeared surprised to discover that someone who had built his career around warmongering wanted him to respond to national security incidents with military force.

That created an opening for Bolton’s former Fox colleague, prime-time host Tucker Carlson, to outmaneuver him. Carlson, who has no experience in government but has a show the president regularly watches, began advising the president privately. In June he played a key role in the president’s last-minute decision to call off the military strike against Iran that Bolton advocated and accompanied him to the Demilitarized Zone between North and South Korea in the national security adviser’s stead.

Carlson was also reportedly undermining Bolton more directly. “For months, the Fox News Channel host Tucker Carlson had been lobbying President Donald Trump to fire John Bolton, telling him it was foolish to keep on his team a top adviser who did not share his views on pressing national security issues,” Politico reported following Bolton’s departure.

The effort apparently included Carlson telling the president that Bolton was leaking to the news media in order to stymie Trump national security moves he opposed, including the planned Camp David meeting between Trump and Taliban leaders, the dispute over which apparently triggered Bolton’s exit.

Carlson took a victory lap on his Monday show, nonsensically denouncing Bolton as “a man of the left” and cheering his removal as “great news for America.”

Bolton’s replacement is as yet undetermined. But Fox may again prove the crucial factor.

One “leading contender,” U.S. Ambassador Richard Grenell, is a former Fox contributor. Another candidate, retired U.S. Army Col. Douglas Macgregor, is a regular guest on Carlson’s show.

There’s also the possibility that Trump will ask Secretary of State Mike Pompeo to also take on the national security adviser role, a proposal floated on Lou Dobbs’ Fox Business show by Sebastian Gorka, who previously worked for Fox and for the Trump White House.

Of course, whoever Trump names will have to contend with the influence of Carlson, who advises the president both privately and through his television and successfully pushed out his predecessor. And while that person may present Trump with his daily national security briefing, the briefing that the president actually pays attention to comes several hours earlier, when the hosts of Fox & Friends tell him what to think about the world.

As Bolton’s tenure shows, the president’s most important advisers aren’t the ones in his White House, but the people he sees on television.