[Want more Canadian coverage in your inbox? Subscribe to our weekly Canada Letter newsletter.]

The concessions on dairy enraged politicians in Quebec, the country’s second-largest province and the center of the dairy industry. All four party leaders vying for votes in the provincial election on Monday rejected the Canadian government’s promise of compensation for farmers.

“It is an expression of the systematic injustice that Quebec is suffering within Canada,” the leader of the separatist Parti Québécois, Jean-François Lisée, told reporters.

During much of the negotiations, Mr. Trump had threatened to impose 25 percent tariffs on Canadian autos and auto parts crossing into the United States, which would have crippled the Ontario economy, putting an estimated 250,000 people out of work, according to one forecast. It would also have become a potent issue in Mr. Trudeau’s re-election campaign next year.

The new agreement — which renames the North American Free Trade Agreement as the United States-Mexico-Canada Agreement — neutralizes that threat by effectively exempting Canada’s exports to the United States. By requiring 40 percent of auto parts to come from so-called “high wage factories,” it could even give unionized Canadian auto manufacturers a leg-up.

“I would argue we are in better shape today than we’ve been in the last 24 years,” Jerry Dias, the head of Canada’s largest private sector union, Unifor, said on a morning Canadian Broadcasting Corporation radio show. “So I’m absolutely thrilled with where we ended up.”

He added: “Look, we hung tough right to the bitter end. We got what we needed. We didn’t fold in the areas that the U.S. wanted us to fold in, so we’re in pretty good shape today.”

Compared with Mr. Trump, who triumphantly claimed the deal would see “cash and jobs pouring into the United States and into North America,” Mr. Trudeau was gracious and understated during his news conference.