It wasn't pretty, but Trump got his trade deal. On Monday, the president announced the United States-Mexico-Canada Agreement (USMCA), a major rewrite of NAFTA. It was a remarkable turnaround in a renegotiation effort that often seemed doomed. And Trump wants you to know that we all have his tariffs to thank for it.

"Without tariffs, we wouldn't be talking about a deal," Trump insisted, taking a potshot at the many, many prominent critics of his hardball tactics. "Just for those babies out there that talk about tariffs — that includes Congress, 'Please don't charge tariffs' — without tariffs, we wouldn't be standing here."

You know what? Trump is probably right.

The Canadians are downplaying it, but the president's threat to impose 25 percent tariffs on automobile imports clearly moved the needle here. "Sources close to the action say the 11th-hour deal came together as a result of deadline pressure, willingness to compromise, and Trump's constant threat of hitting Canada's extensive auto industry with tariffs if it didn't agree to a new deal," Politico reported, saying the latter was "the last detail to be nailed down."

As part of the deal, the U.S. government also sent side letters to both Canada and Mexico, granting each country an exemption on the first 2.6 million cars they might export to the U.S., should Trump's White House ever make good on its auto tariff threat. "That's slightly more vehicles than Mexico has exported to the United States over the last year," The New York Times explained. "And nearly one million more than Canada has exported." Barring some major changes to trade flows between the three countries, Trump just gave both countries a get-out-of-jail-free card for all the passenger vehicles they export in exchange for the final NAFTA deal.

There's also historical precedent for this sort of thing. Back in the 1980s, America's trade deficit was climbing due to an overly strong dollar. In that instance, the threat of tariffs to solve the problem — Japan, in particular, was a target — was coming from Congress, not the White House. But that served as an incentive to get Japan, Germany, France, and Britain to meet the U.S. at the bargaining table. In an agreement known as the Plaza Accord, the five countries struck a deal to change their foreign reserve policies and bring down the value of the U.S. dollar. That closed America's trade shortfall, and the tariffs were avoided.

This actually dovetails with a lot of the criticisms of Trump's reliance on tariffs.

Tariffs are like whack-a-mole. Try to clamp down on one specific country or foreign sector, and supply chains may just shift around. Tariffs can sometimes work to protect a specific domestic sector from the entire world — that's the intelligent defense of Trump's steel and aluminum tariffs, for example. But even that must be weighed against the increased costs for other domestic sectors. The larger point: As a way of permanently rebalancing trade flows, tariffs aren't super useful.

But what tariffs can do is prod trade partners into doing deals that actually lead to deeper structural changes. That's what happened with the Plaza Accord. And that's what seems to have happened with the USMCA.

A few weeks ago I wrote that Trump's NAFTA negotiations likely wouldn't amount to much more than a political stunt. The president seems to have proven me wrong.

The new deal might really improve the livelihoods of workers, and not just American ones either. The deal puts pressure on Mexico to raise automotive workers' wages to $16 an hour and pass labor laws to strengthen its unions. That should begin to even out the imbalances between Mexican and U.S. workers, and lessen incentives for American employers to rely on cheaper labor from the south. Meanwhile, the enforcement mechanisms appear to have at least some teeth. Labor leaders' response to the deal so far has been cautiously optimistic.

More remarkably, America got Canada to agree to scuttle NAFTA's investor-state dispute settlement provision. That's a particularly egregious feature of most modern international trade treaties — including Obama's ill-fated Trans-Pacific Partnership — that effectively allows private companies and investors to sue countries if domestic regulations around labor rights or the environment and so forth cut into business opportunities or profits.

On the downside, the deal doesn't resolve the dispute over Trump's steel and aluminum tariffs. And it extends draconian America-style intellectual property protections to Mexico and Canada as well.

Certainly, this deal isn't a game changer, and it won't roll back all the damage the original NAFTA did. Despite what Trump claims, this is just NAFTA with a few upgrades. Like Dani Rodrik, a Harvard economist who's been very critical of globalized trade, you could argue "the amount of political and negotiating capital that has been spent on [the deal] does not justify any of it." But at the same time, most of the upgrades are in the right direction.

Of course, the new trade deal still has to get through Congress. And none of this is to suggest Trump is some sort of secret strategic genius, or that he even understands the distinction between using tariffs as policy as using them as incentives.

But the fact is he chose to play hardball, and — despite it causing fits of apoplexy among much of the elite — he got some real results.