The US and Canada have reached a new trade deal, along with Mexico, to replace the current North American Free Trade Agreement (Nafta).
The United States-Mexico-Canada Agreement (USMCA) gives the US greater access to Canada's dairy market and allows extra imports of Canadian cars.
The deal has 34 chapters and governs more than $1tn (£767bn) in trade.
US President Donald Trump, who has long sought to change Nafta, said the new deal was "wonderful".
Until recently it looked as if Canada could be excluded from a final trade agreement to replace Nafta which has been in place since 1994.
The new USMCA is intended to last 16 years and be reviewed every six years.
Following the agreement, Mr Trump tweeted that USMCA was a "great deal" for all three countries and solves the "deficiencies and mistakes" in Nafta.
Late last night, our deadline, we reached a wonderful new Trade Deal with Canada, to be added into the deal already reached with Mexico. The new name will be The United States Mexico Canada Agreement, or USMCA. It is a great deal for all three countries, solves the many......— Donald J. Trump (@realDonaldTrump) October 1, 2018
.....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. The USMCA is a historic transaction!— Donald J. Trump (@realDonaldTrump) October 1, 2018
The US has been fighting trade wars on several fronts this year, including placing tariffs on steel and aluminium imports from Mexico and Canada, as part of President Trump's America First policy. Tariffs on cars are also threatened.
What is in the new deal?
The hundreds of pages of the agreement were released in the early hours of Monday and contain updated arrangements for Canada's dairy industry and measures aimed at shifting lower-paid car jobs from Mexico.
- On dairy, US farmers will have access to 3.5% of Canada's $16bn-a-year dairy market.
- On cars, Canada and Mexico have a quota of 2.6 million cars they can export to the US as a protection for their car industry if the US imposes a 25% global tariff on car imports
- In addition, 40% of car parts of vehicles produced in the USMCA area must be made in areas of North America, paying wages of $16 an hour
- On the lumber (or wood) industry, Canada secured protection from US anti-dumping tariffs through the preservation of a dispute-settlement mechanism.
How was the deal reached?
The US made a deal with Mexico in August, but relations with Canada over the trade pact had become increasingly strained in recent weeks.
The Trump administration set Sunday as a deadline for Canada to strike a deal.
A protectionist policy under the Mr Trump has seen the US forge ahead with individual trade deals, rejecting bigger multi-lateral trade agreements and posing a challenge to decades of global free trade.
A win for Trump?
Andrew Walker, BBC Economics Correspondent
Is this a win for President Trump? He certainly has got Canada and Mexico to agree some important things he wanted.
It will be harder, or at least more expensive, for car makers to use parts from outside North America, notably from China. American dairy farmers are getting better access to the highly protected Canadian market.
There may well be some political benefit for him in the forthcoming Congressional elections.
But he has another wider objective - to reduce the imbalance in US international trade, with individual trade partners and globally.
The US imports more than it exports and President Trump wants to change that. Judging whether he has won in that sense will need more time.
However, many economists don't think trade balances are primarily the outcome of trade policy - instead they reflect government borrowing, private investment and savings decisions and international capital movements.
What has been the reaction?
The Canadian dollar jumped to a five-month high and the Mexican peso rose to its highest level for seven weeks on news of the deal.
Meredith Crowley, international trade economist at the University of Cambridge, said the agreement on dairy looked to be a "cosmetic concession" so in one way Canada had done well out of the pact.
She said the insertion of a minimum wage level for car parts workers could lead to similar clauses in other trade deals.
"If it turns out to be very politically popular in the US it could [be used again]," she said,
Canadian dairy farmers were critical. "We fail to see how this deal can be good for the 220,000 Canadian families that depend on dairy for their livelihood," said Pierre Lampron, president of Dairy Farmers of Canada.
However, Canadian Prime Minister Justin Trudeau said: "It's a good day for Canada".
Mexico's Foreign Minister Luis Videgaray said it was a good deal for his country and North America.
The aim is for the agreement to be signed before Mexico's President Enrique Pena Nieto leaves office on 1 December.