Mexico on Thursday expressed "worry and irritation" about U.S. policies to two of President Donald Trump's top envoys, giving a chilly reply to the new administration's hard line on immigration, trade and security.

The U.S. government this week angered Mexico by saying it was seeking to deport many illegal immigrants to Mexico if they entered the United States from there, regardless of their nationality.

It is the latest point of friction between neighbours that have also been at odds over Trump's vow to build a wall on the border and his attempts to browbeat Mexico into giving concessions on trade.

Comments by Trump about a "military operation" to deport criminals added to the tense atmosphere in Mexico City, and prompted a clarification from Homeland Security chief John Kelly.

"There exists among Mexicans worry and irritation about what are perceived to be policies that could be harmful for the national interest and for Mexicans here and abroad," Foreign Minister Luis Videgaray told a news conference.

He was speaking after talks in the Mexican capital with U.S. Secretary of State Rex Tillerson and Homeland Security chief John Kelly, who later met with President Enrique Pena Nieto. The Mexican leader scrapped a summit meeting with Trump in January as tensions rose.

Both sides on Thursday pledged further dialogue on migration, trade and security issues.

Two Mexican newspapers leaked comments from Videgaray that bolstered the perception that Mexico is taking a more robust approach to its dealings with Trump, following jibes that Pena Nieto should stand up to his counterpart.

If the United States taxes imports from Mexico, there will be a response that "hits them where it hurts," La Jornada and Reforma reported Videgaray as saying, based on recordings obtained of a closed door session with lawmakers on Wednesday.

Videgaray warned of counter-taxes and tariffs targeting U.S. congressional districts most reliant on exports to Mexico if Trump started limiting trade.

Kelly and Tillerson were more measured in their words than either the Mexicans or Trump, who on Thursday said a military operation was being carried out to clear "bad dudes" such as gang members and drug lords from the United States.

But Kelly said there would be "no use of military force in immigration operations," and "no, repeat, no" mass deportations. White House spokesman Sean Spicer said Trump's comment was meant to describe the "flawless" manner that U.S. immigration and border authorities worked.

'A COMPLEX TIME'

Looking stern as he stood beside the U.S. visitors, Videgaray said it is "a complex time" for U.S.-Mexican relations, which have gone downhill quickly since Trump's election last November.

Videgaray and Pena Nieto have been criticized at home for being too willing to engage with Trump, who has repeatedly cranked up tension with the country ahead of key meetings.

Opposition politicians and a handful of protesters demanded that Pena Nieto should snub the visitors, and even Economy Minister Idelfonso Guajardo had said the meeting with the president on Thursday might not happen, depending on the tone of the talks in the morning.

Mexico relies heavily on exports to its neighbour. But stakes are also high for the United States, not least because a breakdown in relations with Mexico could affect extensive cooperation on the fight against narcotics and on stemming the flow of Central American illegal immigrants that reach the U.S. border.

The two countries need to strengthen intelligence sharing, as well as take more action to stem the flow of weapons and drug money from the United States and to shut down criminal organizations, Interior Minister Miguel Angel Osorio Chong said.

"Mexico needs the United States, and the United States also needs Mexico, our countries will always be neighbours so the best thing would be to have agreements that work for both equally," Osorio Chong said.

In a concession to Mexican concerns, both Kelly and Tillerson acknowledged the need to stop arms and drug proceeds moving south, and praised Mexico's extensive programs to turn back Central American immigrants travelling north.

"There is no mistaking that the rule of law matters along both sides of our border," Tillerson said.

None of the officials made direct references to the deportation of immigrants from third countries to Mexico, or to paying for the border wall planned by Trump, a red-flag issue for Mexico.