In an address to the nation, Mexican President Enrique Peña Nieto delivered a strong message on President Trump’s decision to send National Guard troops to the southern border. (Mexico Presidency/Reuters)

Mexican President Enrique Peña Nieto delivered his most direct public rebuke of President Trump on Thursday afternoon, in a national address that characterized Mexico as willing to cooperate with the United States but not at the expense of its sovereignty or dignity.

Peña Nieto spoke after Trump signed an order to deploy National Guard troops to halt “a drastic surge of illegal activity on the southern border.” In the past week, Trump has accused Mexico of doing little to stop illegal migration and expressed alarm about a caravan of hundreds of Central Americans who were crossing this country to highlight the plight of migrants — threatening to retaliate against Mexico if it didn’t stop the march.

Peña Nieto, speaking Thursday from the presidential palace in Mexico City, noted that the Mexican Senate and all four leading candidates in the July 1 presidential race had condemned Trump’s comments, adding: “As president of Mexico, I agree with those remarks.”

“President Trump: If you wish to reach agreements with Mexico, we stand ready, as we have proved until now, always willing to engage in a dialogue, acting in earnestness, in good faith and in a constructive spirit,” Peña Nieto said. “If your recent statements are the result of frustration due to domestic policy issues, [due] to your laws or to your Congress, it is to them that you should turn to, not to Mexicans.”

“We will not allow negative rhetoric to define our actions. We will act only in the best interest of Mexicans,” he said.

The address to the nation was remarkable because Peña Nieto has endured, with diplomatic courtesy and sometimes stony silence, about two years of insults and threats from Trump over Mexican immigrants, the trade relationship, border security and the fight against drug traffickers.

The two countries and Canada are locked in tense negotiations over the future of the North American Free Trade Agreement, or NAFTA, which Trump has threatened to rip up if the U.S. government can’t win more favorable terms. Trump has also frequently called for construction of a massive wall on the border.

In the past few decades, Mexico has become a far more cooperative partner of Washington in fighting drug-trafficking, terror threats and illegal migration. But Mexican politicians have called for reducing bilateral cooperation if Trump militarizes the border.

Trump’s move comes as Mexico is in the midst of a hotly contested campaign for president. The leading candidate is Andrés Manuel López Obrador , a center-left populist. On Wednesday, he responded to Trump’s latest moves by declaring that “we will not accept the use of force, the militarization of the border.”

Mexico’s Senate on Wednesday unanimously approved a nonbinding resolution that urged the government to end cooperation with the United States on illegal immigration and drug trafficking because of Trump’s plans to deploy National Guard troops.

Ricardo Anaya, the presidential candidate for a left-right coalition, went further, calling on Mexico to curb its anti-terrorism cooperation until the Guard members are withdrawn.

Despite the outcry, some Mexican analysts and border residents said they expected little practical effect. David Cuauhtémoc Galindo, mayor of the border city of Nogales, said Trump’s comments “generate a certain amount of scandal but no fear” in his city. He noted that most of Trump’s threats — to massively deport undocumented immigrants, expel young “dreamers” who have had temporary U.S. residency or crack down on work visas — had not come to pass. “In practice, on all these themes, it’s the opposite of his speeches,” he said. “As far as the construction of a wall, here in Nogales, we have a barrier that was built years ago. It won’t make a bit of difference.”

Gabriela Martinez in Mexico City contributed to this report.