President Trump threatened to slap tariffs on China and Mexico during his campaign. Now the two nations could team up for their own trade deal.

China's ambassador to Mexico, Qiu Xiaoqi, emphasized that China is ready to talk to Mexico about a "free trade agreement."

"There is no difficulty from China's side," Qiu said last week. "We have great interest in deepening and broadening these ties."

Trump is set to meet with President Enrique Peña Nieto this week at the G20 Summit in Germany. It will be their first meeting since Trump took office. Trump will also sit down with Chinese President Xi Jinping.

Trump's meeting with Peña Nieto is critical for the United States and Mexico: Peña Nieto was supposed to meet Trump in Washington in January. Then Trump tweeted that he should only come if Mexico would pay for the border wall. Peña Nieto canceled his trip and emphasized that Mexico wouldn't pay for the wall.

Related: U.S. and Mexico dodge trade war over sugar

Along with Canada, Mexico and the United States will start renegotiating NAFTA, the free trade agreement between the three nations, in late August.

Trump has threatened to withdraw from NAFTA, and he frequently labels it a terrible deal. Trump blames Mexico and NAFTA for the sharp decline in American manufacturing jobs.

Mexico, meanwhile, is looking elsewhere for new economic alliances. And China say it's game.

Mexico's economic secretary, Ildefonso Guajardo, plans to visit China in September.

But it's not clear how much genuine interest there is in a trade deal, or if the parties are just posturing.

"It is to a certain degree political maneuvering ... to try to establish a united front against the U.S.," says Edward Glossop, an economist at Capital Economics, a research firm. "The economics don't make massive sense, it's not an obvious deal."

Related: Mexican peso fully recovers from Trump plunge

China is a giant market, but experts say it's unlikely China would become a major buyer of Mexican goods because of the great distance between the two countries and the availability of cheaper rivers in southeast Asia.

Like the United States, Mexico has lost lots of manufacturing jobs since China joined the World Trade Organization in 2001, and Mexico was forced to lower tariffs on imported goods from China.

A trade deal that would further cut tariffs on Chinese goods could risk more Mexican manufacturing jobs. That would be a tough sell at home for Mexican leaders.

Although China-Mexico trade ties have grown significantly, up to $43 billion last year, it's much smaller than the $580 billion in trade between the United States and Mexico.

But as long as the fate of U.S.-Mexico relations remains uncertain, the trade chatter with China reinforces Mexico's message to Trump: We're looking elsewhere.

For example, Mexico is accelerating trade talks with the European Union to update an agreement. Both sides hope to finish talks by the end of this year. Mexican officials also want stronger ties to Argentina and Brazil. Those two nations produce two big products -- corn and soy -- that Mexico mostly buys from the United States

"It sends a signal that we have a lot of alternatives," Guajardo said in May about the China trip.

Mexico's economic ministry did not respond to a request for comment on Xiu's remarks.

--A previous version of this story misspelled the name of China's ambassador to Mexico, Qiu Xiaoqi.