Pacific Rim trade ministers failed to clinch a deal on Friday to free up trade between a dozen nations after a dispute flared up over auto trade between Japan and North America, while New Zealand dug in over dairy trade and no agreement was reached on monopoly periods for next-generation drugs.

Trade ministers from the 12 nations negotiating the Trans-Pacific Partnership, which would stretch from Japan to Chile and cover 40 per cent of the world economy, fell just short of a deal at talks on the Hawaiian island of Maui but were confident an agreement was within reach.

"The undergrowth has been cleared away in the course of this meeting in a manner that I would say is streets ahead of any of the other ministerial meetings that we have had," New Zealand Trade Minister Tim Groser said.

"You can see clearly that there are one or two really hard issues, and one of them is dairy."

Deal very close

Australian Trade Minister Andrew Robb said the problem lay with the "big four" economies of the United States, Canada, Japan and Mexico. "The sad thing is, 98 per cent is concluded," he said.

Failure to seal the agreement is a setback for U.S. President Barack Obama, given the trade pact's stance as the economic arm of the administration's pivot to Asia and an opportunity to balance out China's influence in the region.

The talks, which drew about 650 negotiators, 150 journalists and hundreds of stakeholders, had been billed as the last chance to get a deal in time to pass the U.S. Congress this year, before 2016 presidential elections muddy the waters.

The TPP seeks to meld bilateral questions of market access for exports with one-size-fits-all standards on issues ranging from workers' rights to environmental protection and dispute settlement between governments and foreign investors.

The result frustrated negotiators who had toiled through the night to cross off outstanding disputes. U.S. Trade Representative Michael Froman said resolved issues included protection for regional food specialties.

Japan's Economy Minister Akira Amari said that TPP member nations could reach a deal if they meet one more time, and his understanding was that the ministers aim to get together again by the end of August.

New Zealand pushed for opening dairy markets

Despite the progress made, issues pegged as sticking points going into the talks were still blocking a deal after four days of discussions.

New Zealand has said it will not back a deal that does not significantly open dairy markets, with an eye to the United States, Japan and Canada, as well as Mexico.

John Wilson, chairman of the world's largest dairy exporter, New Zealand dairy cooperative Fonterra, arrived to attend the talks late on Thursday to press home the case.

A statement issued on behalf of Canada's dairy, poulty and egg farmers said it's "unfortunate" the talks did not produce a trade deal and that there were "many factors of concern to TPP partners."

"Without an agreement, Canadians farmers continue to face uncertainty which impact their long-term business plans," the statement said.

Ministers also remained apart on how long to protect data used to develop biologic drugs.

U.S. drugmakers want 12 years' protection, but Australia has only five and Chile has none at all. "For us it's vital to have an agreement that balances public policy goals for intellectual property in medicines," said Chilean vice minister for trade, Andres Rebolledo.

U.S. firm on drug patent protection

"The U.S. was on one side of the issue, while practically every other country were on the other side," a source from a non-U.S. negotiation nation said.

"Neither side was prepared to move and all claimed it as a red line issue."

Japan and the United States had largely agreed on the rules of origin for cars, which determine when a product is designated as coming from within the free trade zone and therefore not subject to duties. But they ran into problems trying to get buy-in from Canada and Mexico, which are closely tied in to the U.S. auto industry.

Mexican Economy Minister Ildefonso Guajardo said Mexico was the world's fourth-biggest auto exporter and he made no apologies for standing up for his country.

Japanese automakers source many car parts from Thailand, which is not a member of the TPP, and strict rules would upset existing supply chains.

Canada's International Trade Minister Ed Fast was asked at a news conference whether an election campaign would prevent his government from making a deal during that period.

Canada will 'continue to be at the table'

Fast would only say that: "Canada came to Maui ready to conclude a TPP. We were active constructive partners at the table. When our partners reconvene, and we trust that will be very soon, Canada will continue to be at the table as a constructive partner with a sincere desire to complete these negotiations."

Ottawa says the countries in the partnership represent some 800 million people with a combined gross domestic product of roughly 40 per cent of the global economy.

Supporters of the deal say it would create openings for Canada in dynamic Asian markets for the first time and, in particular, Japan — the world's third-largest economy.

Trade experts argue Canada can't afford to miss out on a massive deal they say would help many domestic industries, including the services sector as well as beef and pork producers.