Washington (CNN) Four days before the deadline, it appeared increasingly unlikely that the United States and Canada would rally to save the three-party NAFTA framework. Intensive negotiations had yielded important progress, but the two sides remained far apart on the most contentious issues.

"It'll be United States and Mexico," President Donald Trump said nonchalantly at a news conference last week, just days ahead of the deadline. "We're very unhappy with the negotiations and the negotiating style of Canada."

It was a gloomy outlook for talks that had persisted for months but had become hung up on matters Trump found himself obsessing over: Canada's restrictive dairy market and the import of auto parts into the United States. The President had taken to railing on those topics during his rollicking campaign rallies.

Personal animus had emerged as well. Trump, a conservative populist, found himself butting heads with Justin Trudeau, the liberal prime minister who's opposed him on matters like climate change and refugees, not to mention trade. Trump denounced Trudeau as "very dishonest and weak" after making an early departure from the G7 meeting Trudeau was hosting in June.

In his news conference last week, Trump also appeared to take aim at Canada's top negotiator, Chrystia Freeland.

"We're not getting along at all," he lamented.

So it was something of a surprise Monday to see Trump hailing a three-country trade agreement from the Rose Garden after negotiators in Washington and Ottawa worked through the weekend to strike an agreement. The final plan opens some of Canada's dairy market to US farmers and will require more of a vehicle's parts to be made in North America in order for it to be free from tariffs.

"Dairy was a deal-breaker," the President said, surrounded by the US negotiating team. "And now for our farmers it's, as you know, substantially opened up much more."

For Trump, a revamped NAFTA reflected an opportunity to fulfill a chief campaign promise, even if the final result was viewed by some economists as more of a rebranding than an entirely new deal. And while Trump took a victory lap on Monday, touting the success of his tariff brinkmanship, he also admitted the future of the new US-Mexico-Canada Agreement was uncertain.

"Not at all confident," was how he answered when asked about the prospects of Congress approving the new deal.

Eleventh-hour talks

On Friday morning, Trump's senior adviser and son-in-law, Jared Kushner, got a call from Trudeau's chief of staff, Katie Telford, and senior adviser Gerald Butts. They wanted to make a final push to reach a deal, two sources familiar close to the negotiations said.

The phone call set into motion a series of phone negotiations over the weekend involving Kushner and US Trade Representative Robert Lighthizer on the US side and the direct involvement of Trudeau's most trusted advisers, leading to an eleventh-hour deal within hours of the midnight deadline on Sunday.

The two sides had struggled to get past key sticking points for weeks, but sources credited the phone call from Trudeau's advisers to Kushner with setting in motion a final effort at the highest levels on both sides to clear the remaining hurdles and salvage the trade deal. Throughout the weekend, Kushner and Lighthizer kept in close touch with Trump, who offered his feedback on the negotiations through Sunday.

Trump's advisers were quick to credit his hardline negotiating approach with getting the US and Canada to a deal.

"Your leadership, vision and grit made this agreement possible. No other person could have done it," Lighthizer told Trump in the Rose Garden on Monday.

Speaking to reporters later, he expanded: "To me the fact that we got a good agreement is all the evidence you need that the President's approach is the good approach, is the right approach. If you're not willing to walk away from an agreement, you're not gonna get one, right?"

Playing to the base

JUST WATCHED Trump: USMCA has a good ring to it Replay More Videos ... MUST WATCH Trump: USMCA has a good ring to it 00:42

While the completion of the NAFTA rewrite amounted to both a campaign promise fulfilled and the successful use of the brinkmanship Trump has brought to the presidency, it also reflected his obsession with branding.

Before the trade deal was even inked, Trump had already decided on its name, an acronym reminiscent of the US Marine Corps: the USMCA.

Long convinced the "NAFTA" acronym was political poison for heartland voters -- including the farmers and industrial workers who propelled him to the White House -- Trump insisted from the beginning that a revamped trade agreement be called something else.

"I'm not going to use the name NAFTA. I refuse to use it," he said last week at a news conference.

On Monday, he felt assured he had made the right choice.

"USMCA," Trump said, reflecting on the acronym. "Has a good ring to it."

As midterm elections near, and after that the beginnings of his 2020 re-election bid, Trump has identified trade as his chief governing priority, one with ample space to tout fulfilled campaign promises and remind voters of a strong US economy.

Unlike other policy areas, Trump has approached trade with his own strong convictions -- built over time as a businessman -- that he wants carried out, according to people familiar with his style. And he has shown a penchant for pitting hardline advisers, such as China trade hawk Peter Navarro, against more moderating voices, such as Treasury Secretary Steven Mnuchin.

So far, Trump has enjoyed the benefit of a roaring US economy, which has absorbed combative trade moves with little impact on the price of goods or in the stock market. But some economists have warned the trade war will eventually be felt by Americans, particularly if new tariffs are applied to Chinese goods, as Trump has warned.

It's an area Trump can rightly claim progress in, even as chaos persists in other areas of his agenda. As was evident Monday, it's a topic he'd rather discuss than, say, his besieged Supreme Court nominee. But even he acknowledged that dairy prices and rules on auto manufacturing couldn't hold the public's attention forever.

"You want to, I guess, get off trade. I don't know, people are falling asleep with trade," he said as reporters in the Rose Garden pressed him to move on to questions about embattled Supreme Court nominee Brett Kavanaugh. "To me it's the most exciting thing you can talk about, right?"