Mexican President Enrique Peña Nieto said Thursday he will not attend a planned Jan. 31 meeting with U.S. President Donald J. Trump, hours after Trump tweeted that the meeting should be canceled if Mexico won’t pay for a border wall.

Peña Nieto’s message on Twitter ended days of uncertainty about how he would respond to Trump’s aggressive stance toward the country, and illustrated the challenges world leaders are likely to face in dealing with Trump’s voluble, Twitter-based diplomacy.

RELATED: Here’s why Donald Trump might actually cut government

“This morning we have informed the White House I will not attend the working meeting planned for next Tuesday,” Peña Nieto tweeted.

“Mexico reaffirms its willingness to work with the United States to reach agreements that benefit both nations,” he added.

In Washington, White House press secretary Sean Spicer responded to the Mexican president’s announcement, saying: “We’ll look for a date to schedule something in the future. We will keep the lines of communication open.”

In this Sunday, Jan. 22, 2017, file photo, President Donald Trump speaks during a White House senior staff swearing-in ceremony in the East Room of the White House, in Washington. Trump’s economic plans are nothing if not ambitious. Yet even to come anywhere near his goals, economists say Trump would have to surmount at least a half-dozen major hurdles that have long defied solutions. (AP Photo/Andrew Harnik, File)
In this Sunday, Jan. 22, 2017, file photo, President Donald Trump speaks during a White House senior staff swearing-in ceremony in the East Room of the White House, in Washington. Trump’s economic plans are nothing if not ambitious. Yet even to come anywhere near his goals, economists say Trump would have to surmount at least a half-dozen major hurdles that have long defied solutions. (AP Photo/Andrew Harnik, File)

Earlier Thursday, Trump had tweeted, “If Mexico is unwilling to pay for the badly needed wall, then it would be better to cancel the upcoming meeting” in Washington D.C.

Trump said Wednesday he would start building a U.S.-Mexico border wall and has vowed to make Mexico pay for it. Mexico opposes the wall and has repeatedly said it won’t pay.

Officials had said Mexico was “considering” canceling after the border wall announcement, but Trump appeared to beat Mexico to the punch in that game of brinkmanship.

Advertisement

Former foreign relations secretary Jorge Castañeda told local media that after Trump’s tweet, “Peña Nieto has no other choice but to say, ‘I’m not going.'”

Trump’s unpredictable style appeared to catch Mexico’s normally quiet and cautious diplomats off guard.

Advertisement
 “I think that, in general, diplomacy is not conducted via Twitter,” Finance Secretary Jose Antonio Meade told Radio Formula.

Mexico’s best-known opposition politician, leftist Andres Manuel Lopez Obrador, tweeted that “in the face of Trump’s latest outburst, don’t go to the meeting, and submit an urgent complaint to the U.N. for human rights violations.”