Twelve nations, including Canada, have reached a tentative deal on a massive Pacific Rim trading bloc billed as the largest-ever deal of its kind, with implications for a staggering scope of industries, workers, and for long-term international relations between countries on four continents.

After five days of marathon, around-the-clock negotiations, a deal was announced Monday to create the Trans-Pacific Partnership _ which would cover 40% of the world’s economy, for starters, and participants predicted it would become the building block for future trade deals.

“Today is a historic day; it is a great day for Canada, it is a great day for Canadians,” Prime Minister Stephen Harper beamed during a news conference Monday in Ottawa.

“With this agreement, the largest economic partnership in the history of the world, Canadian exporters will gain nearly tariff-free access to almost 800 million customers in the Asia-Pacific region… including _ crucially for us _ Japan.”

First, however, the deal requires political approval.

To take effect, the deal must be ratified by the parliaments and lawmaking authorities of all 12 member countries. Canada will be the first political testing-ground _ the agreement lands smack in the midst of a federal election campaign that will decide who will control the Parliament that determines whether it lives or dies.

The drama reached a high point overnight Monday, as a series of delays culminated in an agreement around 5 a.m. on a persistent irritant involving dairy and the future of Canada’s tightly controlled sector.

The Canadian government appears to have guaranteed the long-term entrenchment of the supply-managed sector, which is detested by free-market economists but backed by every major political party, provincial governments, and the domestic dairy lobby.

Canada agreed to 3.25% more foreign imports, a minuscule change compared to what some countries asked for. That means a few more international products like butter on grocery shelves, which is now 90%-dominated by domestic content. For their loss, the government would compensate Canadian farmers billions of dollars under a series of programs over at least 10 years.

It’s a little less clear what impact the deal might have on the auto sector.

The agreement would allow a 17.5% greater tariff-free share of cheaper intercontinental parts compared to the standard set out in the North American Free Trade Agreement (NAFTA), although the formula is apparently complex and includes a series of exemptions. New measures to attract auto investment and protect auto-assembly operations in Canada will be forthcoming shortly, Harper added.

The Canadian envoy to the talks didn’t make any promises specific to workers in any individual sector. But he appeared to insist there would be no net negative impact on Canadian employment as a whole.

“We certainly don’t anticipate that there will be job losses,” said Ed Fast, international trade minister, who suspended his re-election campaign in B.C. for nearly a week to attend the Atlanta talks.

“Obviously there will be some industries that will adapt.”

His New Zealand counterpart Tim Groser had expressed some disappointment earlier this week. In an apparent reference to the smaller-than-hoped-for concessions in dairy, he said completing a deal would require every country to take a deep gulp and swallow a few “dead rats.”

But Groser predicted Monday that the agreement would have far-reaching geopolitical benefits.

“Long after the details of this negotiation on things like tonnes of butter have been regarded as a footnote in history, the bigger picture of what we’ve achieved here remains,” Groser said.

“It is inconceivable that the TPP bus will stop in Atlanta. The TPP bus will move on.”

Several countries including Thailand and Colombia have already mused about joining TPP, which involves North America, Chile, Peru, Japan, Brunei, Singapore, Vietnam, Malaysia, New Zealand and Australia.

The proposed agreement reduces or eliminates barriers in a wide range of sectors and could lead to more Canadian exports of pork, beef, canola, high-tech machinery and a variety of other products.

As one example among hundreds, the beef industry predicts exports to Japan will triple. The 39% current tariff in Japan will become 9% over the next few years, and barriers will completely disappear in other areas.

But voters can’t yet see the fine print.

The actual text of the deal is undergoing a legal review, and it’s not clear when it will be available. The government offered no guarantees at a news conference. It simply expressed hope the 12 countries might manage to make it available in the next few days _ before voters pick a government Oct. 19.

Some members of Canada’s auto sector reacted with consternation, eager to see the details. A coalition of Canadian unions called it a serious blunder _ the result of myriad consultations with multinational corporations and lobbyists in a process that excluded labour and civil society.

But the dairy farmers started celebrating quickly.

The supply-management system appears assured for at least another generation, said Wally Smith, the head of Dairy Farmers of Canada. It’s now survived two big international trade negotiations, including the one with Europe. And with no other big deals on the horizon, it appears the system of quotas and import controls is here to stay.

“The TPP is good for Canada,” said Smith.

“‘Farmers today in Canada are far more confident in their future… as opposed to always having a cloud over their head.”