Mexican officials on Sunday angrily denounced the mass shooting in El Paso and announced a series of unusual actions to protect Mexicans in the United States - including possibly charging the perpetrator in Mexican courts.

President Andrés Manuel López Obrador said six Mexicans were among the 20 killed in the attack Saturday in the border city, and seven more were wounded.

Foreign Minister Marcelo Ebrard said the country would take action under international law.

"Mexico declares its profound rejection and complete condemnation of this barbaric act, in which innocent Mexican men and women lost their lives," Ebrard said in a recorded message on his Twitter feed.

The remarks represented a toughening of Mexico's official reaction to the shootings. On Saturday, López Obrador appeared to play down any US government responsibility for the violence, saying the attack was "a product of [societal] discomposition, of problems certain people have. It's not a generalised issue."

El Paso mass shooting: 20 killed at Walmart store Show all 39 1 /39 El Paso mass shooting: 20 killed at Walmart store El Paso mass shooting: 20 killed at Walmart store CCTV images of the gunman identified as Patrick Crusius The 21 year old, as he entered the Cielo Vista Walmart store in El Paso. The gunman was armed with an assault rifle and opened fire on shoppers at a packed Walmart store, killing 20. KTSM 9/AFP/Getty El Paso mass shooting: 20 killed at Walmart store Law enforcement agencies respond The Texas city’s police chief said the assault on a Walmart store on Saturday, which left another 26 people wounded, was being investigated as a potential hate crime. AFP/Getty El Paso mass shooting: 20 killed at Walmart store Shoppers exit with their hands up Shoppers exit with their hands up after a mass shooting at a Walmart in El Paso, Texas, U.S. August 3, 2019. REUTERS/Jorge Salgado NO RESALES. NO ARCHIVES. STRINGER Reuters El Paso mass shooting: 20 killed at Walmart store FBI released a picture of gunman Patrick Crusius The police officially identified the 21-year-old white male from Allen, Texas, a Dallas suburb some 650 miles east of El Paso. FBI/AP El Paso mass shooting: 20 killed at Walmart store A woman reacts after the mass shooting The attack came just minutes after a far-right manifesto appeared online. If authentic, it would make it the third mass shooting this year announced in advance on the website, which often features far-right and racist content. Reuters El Paso mass shooting: 20 killed at Walmart store Law enforcement responds to the active shooter The racist four-page document, titled “The Inconvenient Truth”, calls the Walmart attack “a response to the Hispanic invasion of Texas” and expresses support for the gunman who killed 51 people at two mosques in Christchurch, New Zealand earlier this year. AFP/Getty El Paso mass shooting: 20 killed at Walmart store A shopper hiding with an old lady behind the return and exchanges counter as the shooting began. Aaron Castaneda/Reuters El Paso mass shooting: 20 killed at Walmart store Ambulances in the car park near the scene It is ranked as the eighth-deadliest mass shooting in modern US history, after a 1984 shooting in San Ysidro, California, that claimed 21 lives. AP El Paso mass shooting: 20 killed at Walmart store Kendall Long (left) comforts Kianna Long (right) who was in the freezer section of Walmart. EPA El Paso mass shooting: 20 killed at Walmart store epa07755367 Police stand at attention after a shooting at a Walmart in El Paso, Texas, USA, 03 August 2019. According to reports, at least one person was killed and at least 18 people injured and transported to local hospitals. One suspect is in custody. EPA/IVAN PIERRE AGUIRRE IVAN PIERRE AGUIRRE EPA El Paso mass shooting: 20 killed at Walmart store Shoppers exit with their hands up. Reuters El Paso mass shooting: 20 killed at Walmart store Shopping carts sit next to a curb after the shooting. EPA El Paso mass shooting: 20 killed at Walmart store El Paso Fire Medical personnel arrive at the scene. AP El Paso mass shooting: 20 killed at Walmart store Walmart employees react after. AP El Paso mass shooting: 20 killed at Walmart store A woman runs to police near the scene. AP El Paso mass shooting: 20 killed at Walmart store Several law enforcement agencies respond. AP El Paso mass shooting: 20 killed at Walmart store People arrive at MacArthur Elementary looking for family and friends as the school is being used a re-unification centre. AP El Paso mass shooting: 20 killed at Walmart store Residents Erica Rios, 36, and Alma Rios, 61, cry outside a reunification centre. AFP/Getty El Paso mass shooting: 20 killed at Walmart store People gather in Juarez, Mexico, in a vigil for the Mexican nationals who were killed. AP El Paso mass shooting: 20 killed at Walmart store A child takes part in a vigil in Ciudad Juarez AFP/Getty El Paso mass shooting: 20 killed at Walmart store Francisco Castaneda joins mourners taking part in a vigil at El Paso High School. Reuters El Paso mass shooting: 20 killed at Walmart store Presidential candidate and former congressman Beto O'Rourke, right, meets with mass shooting survivor, Rosemary, at University Medical Centre Beto O'Rourke Facebook via AP El Paso mass shooting: 20 killed at Walmart store From left, Melody Stout, Hannah Payan, Aaliyah Alba, Sherie Gramlich and Laura Barrios comfort each other during a vigil for victims of the shooting. AP El Paso mass shooting: 20 killed at Walmart store A sign is posted near the scene Getty Images El Paso mass shooting: 20 killed at Walmart store Police cars parked below the Walmart sign block a road outside while investigating. EPA El Paso mass shooting: 20 killed at Walmart store Sherie Gramlich reacts during a vigil. AP El Paso mass shooting: 20 killed at Walmart store A man places flowers at the site Reuters El Paso mass shooting: 20 killed at Walmart store People take part in a rally against hate a day after a mass shooting at the Walmart store Reuters El Paso mass shooting: 20 killed at Walmart store Lupe Lopez holds a picture of a victim during a vigil for victims AP El Paso mass shooting: 20 killed at Walmart store People take part in a rally against hate a day after a mass shooting at a Walmart store, in El Paso, Texas, U.S. August 4, 2019. REUTERS/Jose Luis Gonzalez JOSE LUIS GONZALEZ REUTERS El Paso mass shooting: 20 killed at Walmart store Elsa Mendoza Marquez, a Mexican schoolteacher who was married and the mother of two adult children, was one of the victims Getty El Paso mass shooting: 20 killed at Walmart store People with the Mexican flag and the US flag take part in a rally against hate a day Reuters El Paso mass shooting: 20 killed at Walmart store People raise their arms in the air during a vigil for victims AP El Paso mass shooting: 20 killed at Walmart store People react and embrace each other Getty El Paso mass shooting: 20 killed at Walmart store Women light candles at a make shift memorial at the site of a mass shooting EPA El Paso mass shooting: 20 killed at Walmart store Adria Gonzalez (centre) who is being hailed as a hero for leading some Walmart customers to safety, speaks to the crowd AFP/Getty El Paso mass shooting: 20 killed at Walmart store People hold up their phones AFP/Getty Images El Paso mass shooting: 20 killed at Walmart store Beto O'Rourke speaks to the crowd AFP El Paso mass shooting: 20 killed at Walmart store People react during a prayer and candle vigil organized by the city, after a shooting left 20 people dead at the Cielo Vista Mall WalMart in El Paso, Texas, on August 4, 2019. - A shooting at a Walmart store in Texas left multiple people dead. At least one suspect was taken into custody after the shooting in the border city of El Paso, triggering fear and panic among weekend shoppers as well as widespread condemnation. It was the second fatal shooting in less than a week at a Walmart store in the US and comes after a mass shooting in California last weekend. (Photo by Mark RALSTON / AFP)MARK RALSTON/AFP/Getty Images MARK RALSTON AFP/Getty

But there were increasing indications that the shooting was aimed at Mexicans. Investigators are studying a manifesto that they believe the suspect posted online before the attack; it includes screeds against immigrants.

They made clear, though, that they were alarmed by the rise of anti-immigrant hate speech in their northern neighbour.

"The intentionality of the attack against the Mexicans and the Latino community in El Paso is frightening," Mexico's ambassador to Washington, Martha Bárcena, wrote on Twitter. "NO to hate speech. NO to xenophobic discourse."

President Andrés Manuel López Obrador has vowed to use the full force of international law to prosecute the El Paso gunman (Getty Images)

López Obrador said Mexico didn't want to get mixed up in the US presidential campaign.

But, he said, "We reaffirm our conviction that no one should confront social problems with the use of force or by inciting others to violence."

The Mexican president, who built his political career as a leftist, has surprised his followers and critics alike by agreeing to Trump's demands in recent months for a crackdown on Central American migrants crossing Mexico en route to the US border.

He has consistently highlighted his good relations with Trump.

Analysts believe López Obrador has been anxious to avoid antagonising Mexico's largest trading partner, the recipient of 80 percent of its exports.

But there was no missing the officials' angry tones on Sunday.

"Mexico is indignant," Ebrard told journalists. "But we are not proposing to meet hate with hate. We will act with reason and within the law, but with firmness."

Lupe Lopez carries a photo of Elsa Mendoza Marquez, a Mexican schoolteacher from across the US border who was killed in the El Paso shooting (Getty Images)

He said Mexico would ask US officials how the gunman obtained his weapon. The Mexican government would also ask Mexico's attorney general to consider charging the suspect, identified as a 21-year-old Texan, with committing terrorist acts against Mexicans in the United States.

"As far as I know, this would be the first case of this type in history," Ebrard said. The Mexican government could even seek to extradite the suspect, he said.

"For Mexico, this individual is a terrorist," he said.

The alleged killer will almost certainly be tried first in a US court. If he is convicted, it's unlikely he would be sent to Mexico to stand trial. But the Mexican legal action could help the country gain more information on the investigation.

Ebrard said Mexico would send a diplomatic note to Washington "asking respectfully but firmly that they take a clear, strong position against hate crimes."

Mexico is planning to convene a conference with other Spanish-speaking countries that have immigrant communities in the United States to promote their defence, Ebrard said.

He identified six of the Mexican El Paso victims as Sara Esther Regalado of Ciudad Juarez; Adolfo Cerros Hernández of Aguascalientes; Jorge Calvillo García of Torreon; Elsa Mendoza of Yepomera; Gloria Irma Márquez of Ciudad Juarez; and María Eugenia Legarretta Rothe of Chihuahua City.

Mexican media identified Mendoza as the principal of the Rafael Veloz primary school in Ciudad Juarez, just across the border from El Paso. The newspaper Reforma said she was killed while in the supermarket section of Walmart in the Texas city.

Family members describe how mother shielded her child from El Paso gunman

López Obrador is a longtime defender of Mexican immigrants in the United States. In 2017, a year before his election, he published a book of his speeches and proposals to support Mexican migrants called "Listen Up, Trump."

Shock at the shooting rampage reverberated through Ciudad Juarez. Many residents routinely cross the border to shop or visit family and friends in Texas.

On Sunday, as on most days, there were long lines of cars waiting to head into the United States.

But some drivers told Mexican reporters that they were nervous about their safety on the US side - an ironic sentiment, given that, unlike El Paso, Juarez is violent, with more than 800 homicides recorded from January to mid-July.