Two of Canada's biggest agricultural trade irritants with China have gone away.

A deal reached in Ottawa today means Canadian canola exports will continue through 2020 while both sides conduct research to resolve a shipment quality dispute, while exports of bone-in beef from Canadian cattle under 30 months of age will resume following a BSE-related ban.

The canola compromise came at the last minute during talks between Chinese Premier Li Keqiang and Prime Minister Justin Trudeau on Parliament Hill Thursday.

Li, who is on a four-day official visit to Canada following the United Nations General Assembly meeting in New York, arrived late Wednesday. Intense negotiations went on overnight between Canadian officials and Zhi Shuping, the Chinese minister responsible for the canola file who's also in Ottawa for the visit.

Fearing a disease outbreak, the Chinese have been questioning the quality of Canada's canola shipments and threatening to impose restrictions or cut access to a market that was worth roughly $2.6 billion for Canadian canola producers in 2015.

In this compromise, both sides agreed to conduct additional scientific research to find a "science-based and stable solution," the prime minister said.

"This is great news," Trudeau said. "Our progress on this file goes to show how two countries can collaborate, can solve difficult challenges together."

Prime Minister Justin Trudeau outlines the results of trade discussions with Chinese Premier Li Keqiang which include a new deal on canola. 2:46

A worldwide surplus of the crop allows China to put pressure on its international suppliers.

The size and growth of the largest Asian market, where cooking oil like that derived from canola is in high demand, made resolving this dispute essential.

Canada is the world's largest canola exporter. Over 40 per cent is exported to China.

The dispute was a priority for International Trade Minister Chrystia Freeland during Trudeau's trip to China last month.

Talks continued over the past three weeks on a near daily basis. Agriculture Minister Lawrence MacAulay is planning a trip to China in November.

Under the agreement, trade will continue under current terms while additional research is conducted to determine whether there's a legitimate link between the level of dockage — stems, leaves or chaff that might be found in a grain shipment — and the risk of disease transmission.

Changing the level of allowable dockage in shipments would have added a significant cost for the industry without meaningfully lowering disease risk, the Canadians argued. The two sides have been grappling over this since 2009.

China is the world's largest banquet, and we want Canada to be the caterer. - Brian Innes, Canadian Agri-Food Trade Alliance

"If we hadn't been able to come to an agreement, other exporters would have gotten into that market and we would have lost significant share, but it wouldn't have been easy for China to replace what we send to them," said Patti Miller, president of the Canola Council of Canada.

Until the prime minister and ministers intervened, "we really were at a stalemate over the last couple of years," she said. "We were stuck. I think their engagement in the negotiations, in raising the profile of it, really helped move things along."

Final major BSE holdout

The beef deal — to resume trade in bone-in beef cuts from cattle under 30 months of age — was among several bilateral agreements signed Thursday on a range of issues.

China is among the final few countries that haven't completely reopened their markets following Canada's 2003 outbreak of bovine spongiform encephalopathy (BSE).

Trade in the lowest-risk products — boneless beef from young cattle — resumed in 2010. Thursday's deal adds bone-in beef, worth potentially $10 million in new exports, to start.

China's large market will remain closed, however, to Canadian beef from cattle over 30 months of age. This restriction is considered less commercially meaningful, because good markets now exist for this in North America.

The deal signed between China and Canada Thursday to resume exports of bone-in cuts of Canadian beef is projected to be worth at least $10 million for the Canadian industry. (CBC News)

In a dispute unrelated to BSE, Canada has also not seen eye-to-eye with China on importing fresh (chilled) beef, not just frozen. Now that Air China has added a flight to Edmonton that could carry cargo, Canada wants to start shipping fresh beef cuts too.

Asian markets hold valuable potential for Canadian beef exports not just because of their size and growing middle class: consumers there purchase different cuts from the steaks and hamburgers favoured by North Americans or Europeans.

Taiwan, another significant market, reopened to Canadian beef exports in July, mere days after the visit of Mexico's president to Ottawa yielded a deal to reopen that valuable North American market as of Oct. 1.

Indonesia continues to place restrictions on beef byproducts like bone meal, but most other countries who closed their borders over the issue have now reopened.​

A few, like Australia, have restrictions not for scientific reasons but as a means of protecting domestic business — a symbolic ban with little commercial impact on Canada.

Late seeing this, but ICYMI too: China re-opened to UTM bone-in beef from the U.S. yesterday too. Co-ord move? <a href="https://t.co/uCqP15t7in">https://t.co/uCqP15t7in</a> <a href="https://twitter.com/hashtag/hw?src=hash">#hw</a> —@janycemcgregor

New markets drive optimism

After a long stretch of bad news — bad prices, bad weather and currency fluctuations — "we're really coming to the light at the end of the tunnel," said John Masswhol of the Canadian Cattlemen's Association.

"Our herd sizes haven't grown," he said. "Ultimately what we need is for producers to be confident that if they're going to expand their herds, that they want to know that the return on the investment is going to be there for them in the years ahead."

The canola breakthrough wasn't clear until the last minute: neither the industry nor officials knew they had a deal until the leaders spoke. (Fred Chartrand/Canadian Press)

Export-oriented agricultural sectors need new Asian markets in order to expand.

Both sectors voiced support for Thursday's announcement of exploratory talks with China towards a free-trade agreement. Beef, for example, enters China at a 25 per cent tariff.

"China is the world's largest banquet, and we want Canada to be the caterer," said Brian Innes in a statement on behalf of the Canadian Agri-Food Trade Alliance.

And with the ratification of the Trans-Pacific Partnership on the ropes, Canada needs alternative strategies in Asia.

Australians already have a free-trade deal with Japan and "eat our lunch," Masswohl said.