Fox News hosts and guests have had a major influence on President Donald Trump's willingness to shut down the federal government, according to a report from The New Yorker.

On one occasion, criticism from Fox News hosts almost pushed the president to veto a government-funding bill, an act that would have triggered a shutdown.

The incident is similar to the funding fight in December, when criticism from Fox News hosts and conservative pundits contributed to Trump's decision not to support a bipartisan funding extension.

Trump's reversal on the December funding bill resulted in the longest-ever government shutdown.

Fox News had a big influence on President Donald Trump's willingness to push the federal government into a shutdown, according to a new report.

The New Yorker reported on Monday that Trump was swayed by Fox News anchors and pundits during government-shutdown negotiations, and that advisers were forced to walk the president back from the brink of shutting down the government.

The effect of the Fox News hosts on shutdown negotiations first reared its head in March 2018, according to The New Yorker, when Trump suddenly threatened to veto a bipartisan spending deal just days before the federal government was set to run out of funds.

While Trump eventually did sign the bill, the president was clearly perturbed by the large spending increase included as part of the package and the lack of wall. During a signing ceremony for the omnibus spending bill, Trump called the passage of the package a "ridiculous situation" and threatened to "never sign another bill like this again."

Trump was prepared to veto the bill, the report said, after receiving a wave of criticism from Fox News hosts, pundits, and guests about the deal's lack of funds for a wall along the US-Mexico border. But then-Defense Secretary Jim Mattis was able to convince Trump that a shutdown would be disastrous for the military, and the argument was enough to get Trump to sign the bill.

A former top White House aide told The New Yorker that the sudden reversal and near veto "was all Fox."

Read more: Fox News reportedly killed its story on Trump's alleged affair with Stormy Daniels weeks before the election

Similarly, Trump reversed course on a funding bill in December 2018 after Fox News hosts and guests bashed the lack of wall funding in that deal. But in contrast to the near miss in March, Trump's change of heart actually led to a record-shattering, 35-day shutdown.

Politico reported at the time that Trump's anger over the criticism from Fox News hosts and other conservative pundits was a contributing factor to the president's decision to reject a short-term bipartisan funding bill.

"Lobbying via cable news works," a former senior White House official told Politico.