President Donald Trump erupted at aides in an F-bomb-laden rant a week before Christmas last year, fuming over headlines that announced he was giving up his campaign promise of making Mexico pay for a border wall – and instead handing the country a 10-figure check.

The administration had made a deal with America's neighbors to the south, one that Trump hated, that would send $10.6 billion to four countries. More than half would go to Honduras, El Salvador and Nicaragua. But Mexico would collect $4.8 billion.

The money was meant to help governments tackle poverty, drug trafficking and other violence – the root causes of the illegal immigration wave the president campaigned against. But on December 18, 2018, the national news media he loves to hate framed it as a surrender.

'My f***ing friends are calling me,' the president yelled at aides who had convinced him to make the deal. 'This is the stupidest s**t you’ve ever done. Why the f**k would we do this?'

'I’m not getting $5 billion for the wall, and instead I’m paying Mexico $5 billion? What the f**k am I getting out of this?' he boomed.

President Donald Trump, pictured in the Oval Office in December 2018, erupted at his aides amid a government shutdown fight when news media reported that he had capitulated on his campaign demand that Mexico pay for a border wall

This banner headline on The Drudge Report set Trump off, yelling at aides: 'Why the f**k would we do this?' and 'This is the stupidest s**t you’ve ever done'

Trump had promised to make Mexco pay for a wall but in December 2018 amid a shutdown fight he agreed to send $10.6 billion south (including $4.8 billion to Mexico) in order to alleviate the violence and poverty that drives illegal immigrants to the north

Trump's frustrations boiled over because of a banner headline that flashed on the influential Drudge Report news aggregation website, screaming in both red and black: 'WALL FUNDING OFF TABLE. U.S.A. GIVING $4.8 BILLION TO MEXICO.'

When someone showed the president, he went ballistic, according to 'Border Wars: Inside Trump's Assault on Immigration,' a book by New York Times reporters Michael Shear and Julie Hirschfeld Davis. DailyMail.com obtained a portion of the book ahead of its Oct. 8 release.

'Border Wars' will go on sale to the public on October 8

Trump at the time was getting a hard sell on the deal from Homeland Security Secretary Kirstjen Nielsen and Secretary of State Mike Pompeo. They explained that without the aid money, Mexico wouldn't agree to a plan that would force asylum-seekers to remain there, instead of entering the U.S., while their claims were evaluated.

'Pompeo tried to explain that a lot of the money was private investment – American companies going down to Mexico would turn a profit and create jobs,' Shear and Davis write.

Trump wanted his wall but reluctantly went along, briefly. But as the engine of political media was about to rev, he tried to throw his own vehicle into reverse.

'Let's stick it to the Mexicans,' he told Nielsen and her aides, arguing for an unprecedented complete closure of the southern U.S. border instead.

By then, however, Washington leakers were leaking and his press secretary Sarah Huckabee Sanders was pressing, making a rare concession on the Fox News Channel that Trump might retreat from his demand that Congress appropriate $5 billion to fund his border barrier.

The president, she announced, would settle for $1.6 billion in order to avoid stiffening to the point of causing a government shutdown as he bickered with House Democrats who had just won a majority in the midterm elections

Hours later in the White House Press Briefing Room, Sanders sniffed to reporters that the United States-Mexico-Canada Agreement, Trump's revamp of the Bill Clinton-era NAFTA trade deal, would save the government enough money to make up the difference in wall funding.

The president and his homeland security team have struggled with finding legally defensible and fiscally realistic ways to slow the flood of humanity pouring into the U.S. from the south, much of it consisting of people who are not legally permitted to enter

Kirstjen Nielsen, then U.S. secretary of Homeland Security (left) counseled Trump to cut a deal that would allow Congress to avoid paying for new sections of border wall while permitting the White House to claim the wall would be built with other funds

Secretary of State Mike Pompeo tried to persuade Trump that unless Mexico got aid money, it wouldn't agree to keep asylum seekers inside its borders while they applied for legal status in the United States

'He’s saying that the revenue provided and the money that would be saved through the USMCA deal – we could pay for the wall four times over,' she said, claiming that it 'would provide additional revenue through that deal that would show that Mexico was paying for the wall.'

Ten months later, Congress has yet to ratify the USMCA. The Trump administration has been fighting a string of court battles for clearance to repurpose money from other government agencies, including the Pentagon, to build what the president has promised will be nearly 500 new miles of it by the end of 2020.

But on that December Tuesday, Sanders offered face-saving maneuvers tied to the pending trade deal while journalists pointed out what was obvious to most Americans: Benefits from a new trade pact would go to private citizens and companies, not to the U.S. Treasury.

Trump didn't seem to notice. Shear and Davis write that the president told his staff that night 'that he was going to tweet against the Migrant Protection Protocols deal and blast the State Department for giving money to Mexico, announcing that he was taking the money back.'

Twenty-four hours later, the pendulum had swung back.

'Mexico is paying (indirectly) for the Wall through the new USMCA, the replacement for NAFTA!' the president tweeted. 'Far more money coming to the U.S.'

Trump's capitulation on wall funding came in the context of a bitter budget fight with Democrats in Congress that led to a 35-day shutdown of much of the federal government

By the morning after his F-bomb-laden tirade, President Trump was back to spinning straw into gold, saying his USMCA trade deal would provide the construction money and the Pentagon cvould provide the construction infrastructure

And he announced that '[b]ecause of the tremendous dangers at the Border, including large scale criminal and drug inflow, the United States Military will build the Wall!'

'Border Wars' made news this week for its telling of another moment in the White House's chaotic navigation of immigration politics: Trump's onetime demand that the border wall must have a moat stocked with snakes and alligators.

The president lashed out against Shear and Davis, denying the story and its other details, including his insistence on electrified fencing and a skin-piercing pike atop each wall slat.

In his rage about 'corrupt reporting' while he sat alongside the president of Finland in the Oval Office, he blasted The Washington Post instead of their employer, The New York Times.

He said his communications aides came to him, protesting that the book's vignette was untrue.

'They came to me yesterday. And they said, “Did you say this?”' Trump told reporters, before describing a relapse into anger.

'I said, “Why are you asking that stupid question?”' he recalled.