U.S. President Donald Trump is set to sign a successor to the North American Free Trade Agreement that will make modest revisions to a deal he once called a “disaster,” easing uncertainty for companies reliant on tariff-free commerce.

U.S. and Canadian negotiators worked around the clock this weekend to secure an agreement just before a Sunday midnight deadline, allowing leaders from those nations and Mexico to sign the accord by late November. The 24-year-old Nafta will now be superseded by the U.S.-Mexico-Canada Agreement, or USMCA, covering a region that trades more than $1 trillion annually.

“It is a great deal for all three countries,” Trump wrote on Twitter Monday. He added in another tweet that it solves the many “deficiencies and mistakes in NAFTA, greatly opens markets to our Farmers and Manufacturers, reduce Trade Barriers to the U.S. and will bring all three Great Nations closer together in competition with the rest of the world.”

Canadian Prime Minister Justin Trudeau called it a “good day for Canada & our closest trading partners.” Jesus Seade, the Nafta negotiator for Mexican President-elect Andres Manuel López Obrador, said “Nafta 2 will give certainty and stability to trade.”

The deal caps a turbulent period for relations between the U.S. and Canada, traditionally close allies on national security and trade. The alliance was severely tested by Trump’s aggressive negotiating style and Trudeau’s willingness to stand his ground on key issues such as dairy and dispute settlement.

U.S. equity futures, Canada’s dollar and Mexico’s peso all gained on the news. The loonie climbed to its strongest since May against the greenback, while the Mexican peso rose as much as 1 percent.

Dairy Farmers

The new accord involves improved access to Canada’s dairy market for U.S. farmers, stronger intellectual property provisions, and tighter rules of origin for auto production, according to two senior Trump administration officials who spoke to reporters on condition of anonymity.

Trump had threatened repeatedly to pull out of Nafta, a scenario that business leaders warned would wreak havoc on their supply chains. In force since 1994, the pact eliminated tariffs on most goods. But Trump argued the U.S. had lost jobs to Mexico and seen a trade deficit swell with its southern neighbor.

Critics of the update say it could impose greater regulatory burdens on North American companies and put them at a disadvantage to those elsewhere, while doing little to change the lot of manufacturing workers in the U.S.

The Trump administration had already agreed last month to an updated relationship with Mexico, which increased pressure on Canada to make concessions to join the deal.

The last-minute agreement on Sunday allows the countries to sign the deal with Mexico’s outgoing president, Enrique Pena Nieto, before he leaves office on Dec. 1.

Lawmakers from the three countries would still need to approve the pact. The new deal likely won’t be voted on by the U.S. Congress until 2019. The Democrats may take control of the U.S. House in midterm elections in November, which could undermine Trump’s ability to win approval.

China Tension

Senator Orrin Hatch, a Utah Republican, said he was pleased the administration was able to keep the three-way structure intact, noting that Nafta has been a “proven success” for the U.S. Hatch is chairman of the Senate Finance Committee, the main panel in the upper chamber responsible for trade.

The U.S. is making headway on trade talks with some of its biggest partners except China. Trump signed a renegotiated trade pact with his South Korean counterpart Moon Jae-in last week, and said he had reached agreement with Japanese Prime Minister Shinzo Abe to open trade talks as the U.S. seeks greater access for its car exports.

In contrast, Trump has imposed higher tariffs on $250 billion of Chinese goods, and warned of more to come.

The new trade pact offers Canada and Mexico some cover from the Trump administration’s threat to impose duties on car imports for national security reasons. Canadian auto exports up to 2.6 million units won’t be impacted by any U.S. tariffs on foreign cars. Mexico got the same threshold level, though neither country exports that many cars to the U.S.

Other details of the agreement:

  • The so-called Chapter 19 dispute-settlement mechanism—which hears bi-national anti-dumping and countervailing duties cases and was a major sticking point in the trade talks—remains untouched in the new agreement
  • Steel and aluminum tariffs that Trump imposed on both countries earlier this year remain in effect and will be dealt with separately, according to the U.S. officials. They did not offer a timeline for when those tariffs could be removed
  • Investor-state dispute settlement will be gradually phased out between the U.S. and Canada but remain in place for certain sectors between the U.S. and Mexico, the officials said
  • Canada agreed to raise the threshold for applying duties to cross-border purchases, a key demand from the U.S. Canada’s new so-called de minimis level will be C$150 ($117) for customs duties, up from C$20 now, and C$40 for sales taxes