TORONTO — U.S. President Donald Trump vowed to make Canada pay after Prime Minister Justin Trudeau said he wouldn’t be bullied in trade talks. Trump called Trudeau “weak” and “dishonest.” He threatened tariffs on cars and slapped them on steel.

The attacks on America’s closest ally left a bitter taste, but Canadians mostly feel relieved after reaching a new trade agreement with Trump. Many said it could have been a lot worse. Canada avoided auto tariffs and maintained access to the key American market.

The U.S. made few, if any concessions, while Canada provided more access to its dairy sector and allowed Washington to possibly prevent Canada from reaching a free trade deal with China. Canada also was not able to remove steel and aluminum tariffs.

“We were definitely over the barrel in this negotiation,” said Peter MacKay, an ex-Canadian foreign minister. “We have survived it. We have survived the 14 roller coaster months of a very unpredictable president.”

About 75 percent of Canada’s exports go to the U.S., so preserving major elements of the North American Free Trade Agreement was crucial. Canada is one of the most trade-dependent countries in the world, and Trump’s talk of ripping up that deal and imposing a 25 percent tariff on the auto sector posed a serious economic threat.

“We didn’t ask to reopen NAFTA. We were dragged into it and we dealt with it the best we could,” said Jean Charest, a former Quebec premier.

“We were always on the defensive,” he said. “We always knew from the outset that we weren’t going to be making spectacular gains.”

Foreign Minister Chrystia Freeland, Canada’s chief negotiator, called it a victory because it maintains tariff-free access to the U.S. for most of the country’s exports. The Trump administration’s most contentious demands, like its insistence that 50 percent of autos imports be American-made, were dropped. Canada also kept a NAFTA dispute-resolution process that the U.S. wanted to jettison.

But there is a widely shared belief that Canada made concessions and the U.S. did not.

“The concessions were all from Canada and Mexico,” MacKay said. “All of them. The only thing that the United States gave up was more demands.”

Roland Paris, a former foreign policy adviser to Trudeau, expressed relief that the deal is done but worried about the long-term relationship between the two countries.

“Canadians won’t forget Trump’s disgraceful treatment of Canada. Our economic partnership has been reaffirmed, but trust can’t be rebuilt with the stroke of a pen,” Paris tweeted.

Canada could have lost 60,000 jobs in a trade war and taken a 1 percentage percent hit to its GDP — a significant drop because Canada’s economy is projected to grow just 2 percent next year, according to estimates from the C.D. Howe Institute, a Toronto-based think tank.

Jerry Dias, president of Canada’s largest private-sector union, Unifor, said he was thrilled the auto tariff threat has been lifted.

The agreement also potentially restricts Canada and Mexico from reaching a free trade agreement with China and other “non-market” countries. If Canada or Mexico signed a deal with China, the U.S. could terminate its trade agreement with Canada or Mexico on a six-month notice. That may pose a problem for Canada which is eager to diversify its trade.

Like many other Canadians, Larry Rosen, chief executive of clothing chain Harry Rosen, feels Canada hasn’t been treated with respect, specifically with reference to the personal attacks and steel exports that are still subject to U.S. tariffs over what Trump calls national security concerns.

“Even when I’m dealing with a hard business issue, I don’t belittle people, I don’t insult them,” Rosen said. “As a Canadian, the whole approach that has been taken (by the U.S.) has been offensive and I don’t think Canadians will forget it.”