Among other threats targeting Mexico during his election campaign, President Donald Trump harshly criticized the North American Free Trade Agreement, a 23-year-old tripartite deal that removed tariffs and significantly increased commerce between Canada, the United States and Mexico.

Renegotiation of the deal is likely to start late this year.

Read:Trump reportedly weighing Nafta withdrawal

As Trump has pointed out, Nafta contributed to a U.S. trade deficit with Mexico reaching $63.2 billion last year. This is the country’s fourth-largest trade deficit, after China, Japan and Germany. America’s deficit with the other Nafta nation, Canada, was slightly over $11 billion in 2016.

But that’s only part of the story. Remove cars and auto-part imports, for example, and the U.S. deficit with Mexico virtually disappears.

Overall, Nafta has been beneficial to Mexico, Canada and the U.S. alike. Since it was signed in 1994, foreign direct investments in Mexico have averaged 2.6% of GDP (compared to 1% for two decades before Nafta). At present, annual bilateral trade between the U.S. and Mexico is running at $580 billion.

Read:Trump calls Nafta the ‘single worst trade deal’ — but here’s the truth

U.S. agricultural exports to Mexico have surged

Much of Trump’s outdated protectionist rhetoric hinges on manufacturing, outsourcing of jobs to Mexico and immigration. Agriculture — a key link between the two nations — doesn’t seem to have entered his calculations.

Globalization may have contributed to manufacturing job losses in the U.S., but it has had significant benefits for the American agricultural sector. U.S. exports of agricultural products to Mexico have increased nearly fivefold since Nafta was signed.

“ Around 98% of the corn that forms a staple of the Mexican diet comes from the U.S. Mexico also buys 7.8% of all U.S. pork production. ”

For the 2014–15 crop marketing year, U.S. corn production was 360 million metric tons, 13% of which was exported. Mexico accounted for 23% of these exports.

In 2016, Mexico imported $17.9 billion in American agricultural products: $2.6 billion in corn, $1.5 billion in soybeans, $1.3 billion in pork and $1.2 billion in dairy products.

Around 98% of the corn that forms a staple of the Mexican diet comes from the U.S. Mexico also buys 7.8% of all U.S. pork production.

What has been good for U.S. farmers has actually hurt Mexican agriculture. Lulled by a steady supply of cheap U.S. farm products and low transportation costs, and assuming that the good times will continue, Mexico hasn’t diversified its agricultural imports. It depends heavily on U.S. farmers to feed its people, endangering Mexico’s long-term food security.

Where American agriculture is losing ground

The U.S. is the world’s top exporter of agricultural products, but there are other global breadbaskets, including Brazil, Australia, Russia, Argentina and Ukraine. As these rivals have adopted more modern farming and agricultural practices and improved their transport and product-handling infrastructure in recent years, America’s global export share has been steadily declining.

Political decisions have at times accelerated this decline. In 1979, the U.S. banned grain sales to the then-Soviet Union because of its invasion of Afghanistan. This forced the U.S.S.R. to improve its own grain production, and, in 2016, Russia surpassed the U.S. for the first time in wheat exports.

Might Donald Trump’s administration be facing a similar watershed moment for American agriculture?

As America threatens to close its agricultural export door, it has damaged Mexico’s confidence in the reliability of its major supplier — perhaps permanently. In a January 2017 Washington Post opinion piece, former Mexican president Ernesto Zedillo wrote that it was a “waste of time” to play “Nafta tweaking games with the Trump administration”.

How Long Will the Nafta Renegotiation Take?

Though Mexico currently has free trade agreements with 45 countries (more than any other country in the world), agriculture has consistently been the most sensitive issue in Mexico’s free trade agreements. Trump has changed that.

Today, the country is accelerating its search for new partners to meet its national agricultural needs. Sensing long-term opportunities, Brazil and Argentina — both major exporters of beef, wheat, soybeans and other prized U.S. agricultural products — are elbowing their way to the front of the queue. Neither currently has a free trade agreement with Mexico.

Mexico Deputy Economy Minister Juan Carlos Baker has said that the country is “pretty far advanced with Brazil. Argentina is a few steps behind”, confirming that Mexico could offer South American producers terms similar to those currently enjoyed by American farmers “if it suits us”.

Brazil Agriculture Minister Blairo Maggi has announced that the country is “back in the game”.

Mexico is also discussing bilateral deals with Australia and New Zealand, two other main food-exporting countries.

In addition to government-to-government agreements, companies that produce and trade agricultural products are also seeing Mexico’s vast import market with new eyes. One of them is Adecoagro AGRO, -1.59% , which owns and leases some 434,000 hectares of farmlands in Brazil, Argentina and Uruguay and harvests two million tons of agricultural products annually.

The New York-traded Buenos Aires-based firm, whose major shareholders include the Hungarian-American investor George Soros, the Dutch Pension Fund PGGM and the Qatar Investment Authority, currently exports agricultural products such as corn, wheat, soybean and cotton to Africa, Asia and Middle East.

It sees Nafta-related uncertainties as an opportunity to penetrate the Mexican market, especially if Brazilian and Argentinian products are granted favorable U.S.-style export arrangements.

Mexico’s brighter outlook

In addition to diversifying its trading partners, Mexico is also seeking to stimulate its domestic agricultural production, according to several government officials and advisers.

New policies currently under consideration would incentivize farmers to produce more, modernize their farms, increase crop yields, and expand cultivable areas. The country is also looking to improve its transportation and storage infrastructure, including ports that could be used for bulk grain imports.

All of these efforts will help put Mexico on more equal footing with the United States in future Nafta negotiations. So, too, would retaliatory measures against a threatened U.S. border tax. (And, anyway, if the U.S. does decide to implement one, the market is likely to sell off Mexican peso aggressively, making Mexican products cheaper even with new tariffs.)

Read:Dollar advances against Mexican peso, Canadian dollar on reports U.S. may withdraw from Nafta

Like the 1979 U.S. grain ban that helped Russia improve its agriculture, Trump’s vituperation may prove beneficial to Mexico (and bad for the U.S.) in the decades to come.

In the meantime, Mexico is facing a tough political and social landscape. President Enrique Peña Nieto’s approval rating is nearing single digits and the economy is performing anemically, with 2017 economic growth predicted to be a paltry 1%.

With a presidential election approaching in 2018, Peña Nieto is unlikely to hard sell to his people a new Nafta that doesn’t appeal to Mexicans. So it would be good politics, too, to play hardball with Trump.

Mexico has more policy options than it thinks. And it may have less to lose than its northern neighbor.

If ending Nafta hurts farmers in America’s Corn Belt, who voted overwhelmingly for Trump, there goes the Republican’s reelection.

Now read:The real reason for the trade deficit? Our spending habits

Cecilia Tortajada is a senior research fellow at the Lee Kuan Yew School of Public Policy at the National University of Singapore. Asit Biswas is a distinguished visiting professor at the Lee Kuan Yew School of Public Policy and is a contributor to this article.