WASHINGTON -- A new era in North American free trade dawned in the dead of night Sunday as a 14-month NAFTA modernization effort between Canada, the U.S. and Mexico finally came to fruition with just hours to spare before an end-of-weekend deadline.

What began as a marathon in the summer of 2017 ended in a flat-out sprint as negotiators in Ottawa and Washington worked around the clock to put the finishing touches on language adding Canada to the deal reached over the summer between the U.S. and Mexico.

"It's a good day for Canada," was all Prime Minister Justin Trudeau would say as he left a late-night cabinet meeting in Ottawa that capped several days of frenetic long-distance talks that included Foreign Affairs Minister Chrystia Freeland and U.S. Ambassador David MacNaughton.

Details remained sparse, but U.S. administration officials say the deal -- newly christened the U.S.-Mexico-Canada Trade Agreement, or USMCA -- provides increased access to Canada's dairy market for U.S. producers and limits the American impact of Canada's controversial supply management system for dairy and poultry products, long a thorn in the side of President Donald Trump.

It also appears to preserve the key dispute-resolution provisions -- Chapter 19 -- which allows for independent panels to resolve disputes involving companies and governments, as well as Chapter 20, the government-to-government dispute settlement mechanism.

Canada fought hard to retain Chapter 19, a holdover from NAFTA that U.S. trade ambassador Robert Lighthizer fought tooth and nail to eliminate.

And on the matter of Section 232 tariffs, Trump's trade weapon of choice, U.S. officials say the new deal doesn't address them directly, since they are a matter for the Department of Commerce. But on a late-night conference call with reporters, they said the two sides had "reached an accommodation" on the issue.

Dan Ujzco, an Ohio-based international trade lawyer who'd been briefed on the details, said he expected a detente on the tariff issue to be negotiated separately in the coming days.

"USMCA will give our workers, farmers, ranchers, and businesses a high-standard trade agreement that will result in freer markets, fairer trade and robust economic growth in our region," Freeland and Lighthizer said in a joint statement.

"It will strengthen the middle class, and create good, well-paying jobs and new opportunities for the nearly half billion people who call North America home.

"We look forward to further deepening our close economic ties when this new agreement enters into force."

Insiders got wind of a breakthrough just hours before U.S. and Mexican trade authorities were set to publish their own trade agreement without Canada as a signatory.

Federal cabinet ministers were summoned to a late Sunday meeting at the Prime Minister's Office near Parliament Hill, while the White House convened its own late-night conference call just an hour before the midnight deadline.

"In short, we think this is a fantastic agreement for the U.S., but also for Canada and Mexico," said administration officials, who cheered the fact that U.S. dairy ranchers would soon have "substantial" expanded access to lucrative markets north of the border.

They described the central elements of the deal as a "template" that would become the "playbook" for all of the Trump administration's future trade deals, including new and stronger rules of origin on autos and mechanisms to ensure agreements don't become "stale and outdated."

 "It's a great win for the president and a validation of his strategy in the area of international trade."

In Ottawa, PMO officials say there will be another cabinet meeting Monday and a news conference likely as well.

Meantime, congratulations were being offered among key stakeholders who have been on the edge of their seats waiting to see if Canada and the United States would find common ground.

An agreement on how to treat the auto sector, reached this summer between the United States and Mexico, was central to a revamped NAFTA going ahead.

But the U.S. and Canada had trouble dealing with other areas in the pact, including Canada's dairy industry, its insistence on a strong dispute settlement mechanism and concerns about intellectual property and culture.

After weeks of hunkering down in Washington, Freeland and David MacNaughton, Canada's ambassador to the U.S., had spent the day in Ottawa taking part in an aggressive, long-distance, last-minute push to get Canada into the trilateral free trade deal ahead of a key congressional deadline.

Central to the discussions Sunday was an effort to secure some sort of assurance that would allow Canada to avoid the dreaded Section 232 tariffs on steel and aluminum, and to protect itself from Trump's repeated threats to impose similar measures on autos.

The Canadian Chamber of Commerce said it was relieved that an agreement in principle had been reached. But President Perrin Beatty said in a statement, the details of the text needed a closer look before a final verdict could be rendered.

"Specifically, we will seek clarity on how the agreement addresses the existing tariffs on Canadian steel and aluminium, as well as how it will ensure that tariffs and quotas upon Canada's auto sector exports will be avoided," Beatty said.

Canada had been offering the Americans better access to its protected dairy market in the hopes of winning American concessions on dispute settlement.

Trudeau has promised repeatedly to keep the country's supply management system intact, despite pressure from Trump. The issue has also figured prominently in Quebec, where voters go to the polls in a provincial election on Monday.

-- With files from Mike Blanchfield and Terry Pedwell in Ottawa