Are China and Mexico getting closer together? It sure looks that way. And why not? With U.S. President Donald Trump threatening to end the North American Free Trade Agreement (NAFTA), build a wall on the southern border, and deport thousands of migrants who came as children from Mexico to the United States, the reliability of the United States as a long-term partner is being openly debated in Mexico.

That’s a problem for a country as economically intertwined with the United States as Mexico, exporting more than eight of every 10 dollars to the United States while importing a similar percentage. Indeed, since 1994 NAFTA has been the glue that has both strengthened and expanded the economic partnership while also supporting broader cooperation in security matters and underwriting Mexico’s democratic transition at the turn of the century.

Nonetheless, as the United States pulls back, Mexico is not without options. During the November 2016 APEC leaders’ meetings in Peru, in fact, President Enrique Pena Nieto made clear that, while the United States would remain the logical and preferred economic partner for Mexico, his government would look to explore additional options to the extent it may become necessary. That time may now have arrived.

From September 4-6, 2017, Pena Nieto was in Xiamen participating in the Dialogue of Emerging Economies on the margins of the 9th BRICS summit, meeting directly with President Xi on September 4. This was his fourth trip to China, an extraordinary number of visits for a head of state elected in 2012, and their seventh meeting overall. (Xi has traveled to Mexico once; other meetings were in third countries.) In addition, meetings of cabinet ministers and various trade delegations have become almost routine.

The avowed purpose of this latest trip of the Mexican president, which occurred even as officials from the United States and Canada were in Mexico City conducting the second round of NAFTA negotiations, was to build further economic links with BRICS nations, in particular China. Relations between Mexico and China have not always been smooth, for a variety of reasons. Still, Mexico’s exports to China reached $5.4 billion in 2016 while importing over $65 billion. China is Mexico’s third largest trading partner, and both parties are now showing at least rhetorical interest in a freer trade agreement.

Arguably, however, the real if unstated purpose of Pena Nieto’s visit to China while NAFTA negotiations were in progress in his own country was to show Mexico’s ability to diversify its economic relations beyond the United States. This is similar to the statement made by Canada’s Prime Minister Justin Trudeau who paid a state visit to China almost exactly one year ago.

Of course, economic relations incorporate not just trade but also investment. After several mishaps with Chinese investors earlier in Pena Nieto’s administration, both governments are looking to put the past behind and to focus on what can be done together going forward. Mexico’s newly open energy sector is of prime interest for China, which has recently won bids for properties in the Gulf of Mexico and is looking to expand further into Mexican energy production. China has announced plans for hundreds of billions of dollars of investment in Latin America and the Caribbean overall, and Mexico wants to ensure that it receives a healthy share of the investment that may materialize. Energy is one of several sectors where mutual interest is very high. In addition, Xi praised cooperation in telecoms, autos, and finance, and opened the door to enhanced collaboration in clean energy, manufacturing, and air transportation. He also invited Mexico to take a leading role in launching China’s Belt and Road Initiative in Latin America, a step that he previewed last November in Lima.

Taken together, this is a remarkably ambitious agenda for two nations that share little in common, are geographically distant, and whose economies traditionally compete with each other rather than complement each other. For this reason it is appropriate to remain at least a little bit skeptical that the full promise of burgeoning relations will be realized. Adding to this, Mexico will hold presidential elections in 2018, and Pena Nieto will be out of office by the end of next year. His replacement will have a lot to say about the nature of bilateral relations with China going forward.

But politics makes strange bed-fellows, and the actions of the Trump Administration may be contributing to a re-think of the value of an enhanced bilateral relationship between China and Mexico. NAFTA may or may not be modernized successfully, strengthening the North American relationship. The outcome is, as this point, highly uncertain and subject to rapid changes. Even if negotiators are able to conclude and pass a modernized NAFTA within the current political climate, the run-up to negotiations has shaken Mexico out of its complacency in taking for granted relations with the United States. It has caused Los Pinos, the Mexican White House, to look actively for alternatives.

China is an obvious option to explore, even as China views Mexico as the largest remaining Latin American economy with which it has yet to develop a robust and lasting relationship. At this point, the incentives for bilateral cooperation continue to grow.