Open this photo in gallery Prime Minister Justin Trudeau arrives at his office for NAFTA talks Sept. 30, 2018, in Ottawa. Dave Chan/The Globe and Mail

Canada and the U.S. have reached a tentative deal to overhaul the North American free-trade agreement after intensive weekend talks, trading access to Canada’s protected dairy market for the preservation of a key dispute-resolution system and exemption from threatened auto tariffs.

President Donald Trump signed off on the agreement late Sunday night, said four sources with knowledge of the closed-door negotiations. Prime Minister Justin Trudeau convened a late Sunday cabinet meeting at his office in Ottawa. The Mexican Economy Ministry, meanwhile, said it presented text of the preliminary deal to the Mexican Senate.

NAFTA will be renamed the United States-Mexico-Canada Agreement – or USMC, with the United States posting the text of the agreement online. Mr. Trump had previously indicated he wanted to do away with the phrase “NAFTA."

Story continues below advertisement

Read the full text of the agreement

Campbell Clark: Canada made concessions on NAFTA but new deal avoids major damage to economy

Globe in Mexico City: Mexico may have lost most with new NAFTA deal, but calls it a win

In a statement late Sunday, Foreign Affairs Minister Chrystia Freeland confirmed that Canada and the United States had settled upon a “new, modernized trade agreement for the 21st Century: the United States-Mexico-Canada Agreement.”

Canada preserved the Chapter 19 dispute settlement provision, satisfying Mr. Trudeau’s long-standing red line in the negotiations. The deal will also keep in place protections for Canadian cultural industries.

Mr. Trump, for his part, gained the right for American farmers to sell more products into Canada’s tightly-controlled supply managed dairy system, his major trade complaint with Canada over the last year and a half.

A side agreement would see the Trump administration guarantee it will not impose tariffs on most auto imports from Canada.

Story continues below advertisement

The deal would also allow Canadian consumers to purchase five times more foreign merchandise online without paying import duty than they are currently allowed.

While the agreement did contain some Canadian concessions, it mostly limited the damage to Canada from Mr. Trump’s protectionist trade policies. But Canada failed to conclude a deal to get steel and aluminium tariffs lifted. Mr. Trump imposed the levies in June, insisting they were the consequence of Canada not signing onto a NAFTA deal, but two U.S. officials speaking at a background briefing said there was no agreement to lift them despite Canada agreeing to the deal. Those officials said there have been negotiations over the tariffs, but they have not reached a conclusion.

Canada also agreed to increase protections for pharmaceutical patents to 10 years, a significant victory for the U.S. in an area it has long pushed Canada on, the U.S. officials said. Canada has long resisted increasing protections for pharma in order to keep drug prices low and help its own generic drug industry.

The U.S. dropped a major demand to gut Chapter 20, a different dispute resolution provision, and it will instead remain exactly as it is now, the U.S. officials said. Chapter 11, however, will be phased out between the U.S. and Canada, the officials said. The provision had allowed corporations to sue governments at special tribunals for interfering in their business. The chapter will, however, remain in place in a scaled-back form in Mexico.

The U.S. has been pressing Canada to make a deal since late August, when the Trump administration reached a preliminary NAFTA pact with Mexico.

Mr. Trump wants to send text of the deal to Congress Monday, starting a 60-day countdown to a final signing. He has repeatedly threatened to decimate Canada’s auto industry with 25-per-cent tariffs if an agreement is not reached.

Story continues below advertisement

Canadian and American negotiators spent all weekend in talks, conducted via videolink, in a bid to reach the deadline, said two government and industry sources.

Ms. Freeland and Ambassador to the U.S. David MacNaughton hunkered down with Mr. Trudeau’s top aides, Katie Telford and Gerald Butts, at the Prime Minister’s Office in Ottawa to work through the deal.

Mr. MacNaughton said the negotiating team was pleased with the result. “If a few months ago you had told me we would get a deal like this, I would have taken it in a nanosecond."

Canadian Labour Congress President Hassan Yussuff, who sits on the government’s NAFTA advisory panel, said the tentative deal "will be a relief for industry but also for our members who are worried if the industry is not protected.” Mr. Yussuff noted Mr. Trudeau will hold a news conference Monday to lay out the details of the deal.

Canada will give U.S. farmers access to the Canadian dairy market greater than the 3.2 per cent granted to 10 other countries under the Trans-Pacific Partnership. Ottawa will also change a rule that had largely excluded U.S.-made ultrafiltered milk, a cheese-making ingredient, from Canada.

The deal will preserve Canada’s supply management system, which uses a combination of quotas and tariffs to guarantee returns for Canadian farmers.

Story continues below advertisement

But giving a larger percentage of the market to the U.S. without tariffs is certain to rankle the dairy lobby, which wields significant political influence, particularly in Quebec, which holds a provincial election Monday.

“As the national association of dairy farmers in Canada, we have not been consulted by the government” about the potential concession, said Lucie Boileau, a spokeswoman for the Dairy Farmers of Canada.

For its part, Canada will keep Chapter 19, which allows it to challenge punitive American tariffs on imports at binational panels rather than in the U.S. court system.

The system has proven useful in the past for protecting softwood-lumber exports from duties.

Canada also bowed to U.S. demands to raise its de minimis threshold – the amount of online merchandise consumers can buy across international borders without paying import duty – from $20 to $100, said the sources.

The move, which was opposed by the Canadian retail industry, was agreed to by Canada in exchange for still being able to collect sales tax on the purchases, a source said.

Story continues below advertisement

The framework deal also includes a side agreement to have Mr. Trump exempt Canadian autos from future levies. In exchange, Canada agreed to an auto quota system similar to one Mexico accepted in August.

Under the terms of the deal, all Canadian-made autos and auto parts under a specific quota – which is higher than current export levels – are exempted from any possible Section 232 national-security tariffs.

In addition, any Canadian-made autos that exceed the quota but that meet stringent new auto-content rules would also be exempted. Therefore, Washington could only impose tariffs on autos that exceed the cap and fail to meet the new rules.

One U.S. industry source briefed on the talks said Canada and the U.S. had discussed quotas or export restrictions on steel and aluminium, which designed to exempt current Canadian exports while discouraging steel and aluminium from other countries being routed through Canada into the U.S. market.

Jesus Seade Kuri, the chief negotiator representing Mexico’s president elect, Andres Manuel López Obrador, said he was delighted and relieved with that it was a trilateral deal. ""The fact that Canada is in will be very popular across the board."

He predicted that the deal would be broadly popular with Mexicans, although the tougher rules of origins on cars would draw criticism - but in the long term they will prove positive, he said, since "you have a whole region that is becoming more protectionist ... and now we are inside the curtain. That's beneficial for Canada and Mexico."

Story continues below advertisement

He said that in hindsight, it was possible that Mexico could have got through the negotiations without giving up as much as it did. “Probably Mexico could have been tougher and resisted concessions -- in the car industry, for example -- it probably was a little too much but at same time that’s difficult to say, because Trump was so hell bent on getting out of NAFTA.”

With files from Stephanie Nolen in Mexico City