NEW YORK (Reuters) - Mexican Economic Minister Ildefonso Guajardo Villarreal said on Wednesday that Mexico was prepared to “talk to the devil” should Republican Donald Trump win the U.S. presidential election in November.

Mexico's Economy Secretary Ildefonso Guajardo Villarreal speaks during a news conference after signing an agreement in Rio de Janeiro, March 9, 2015. REUTERS/Pilar Olivares

Villarreal gave the response during a forum sponsored by the Americas Society/Council of the Americas in New York that featured the presidents of Peru, Chile and Colombia, with Villarreal standing in for Mexican President Enrique Pena Nieto.

“We cannot afford to risk a very important bilateral agreement,” Villarreal said at the event on the sidelines of the United Nations General Assembly when asked about the possibility of Trump becoming president.

“If we have to talk to the devil to guarantee the safety and future of the Mexican people in the U.S., Mexico will talk to the devil.”

Trump, who is facing off with Democrat Hillary Clinton in the Nov. 8 election, has infuriated Mexicans by vowing if elected to build a border wall with Mexico to keep out illegal immigrants - which he said that country would pay for.

He has also threatened to carry out mass deportations, renegotiate the North American Free Trade Agreement among the United States, Mexico and Canada, and in announcing his candidacy last year, referred to some immigrants from Mexico as rapists and drug runners.

When other leaders at the event were asked about Trump, Peruvian President Pedro Pablo Kuczynski said in a joking manner: “Oh, no, we’re not worried at all.”

He then added: “That’s the thing Trump doesn’t understand. The Latins have helped the U.S. immensely. They have kept the U.S. young ... and Social Security that was supposed to go bust years ago is still working because of (Latino immigration).”

Chilean President Michelle Bachelet said: “I just want to give a general perspective: I think the world needs more female presidents.”

The leaders also discussed opening relations with Venezuela, the Trans-Pacific Partnership trade deal and the role of the Pacific Alliance, which includes Colombia, Chile, Mexico and Peru, as a major trade partner with the United States. The United States and 48 other nations are so-called observer states within the alliance.