"We lament these acts and we affirm our conviction that social problems should not be resolved with use of force and incitement of hatred", Lopez Obrador said, cited by Reuters.
Mexican Foreign Minister Marcelo Ebrard said that his department would take all measures to protect compatriots in the United States against the background of the shooting.
"The President of the Republic instructed me to translate Mexico's indignation, first of all, into defense of the affected families, and then into legal, effective, quick and convincing actions, so that Mexico would help and demand the creation of conditions for the protection of the Mexican-American community and Mexicans in the United States. What happened is unacceptable", Ebrard said in a video address.
Over 20 people were killed and 26 more injured after a gunman opened fire in a Walmart in the Cielo Vista Mall in the city of El Paso, Texas, on Saturday evening. Hours later, another gunman attacked people in the city of Dayton, Ohio, killing nine and injuring at least 26.
Both gunmen reportedly used AK-type military assault rifles. There has, however, been no direct link to connect the two massacres, according to media reports.
The shopping centre in El Paso, where the shooting took place, is located in close proximity to the US-Mexico border. A significant part of its visitors are Mexicans who come to El Paso to shop.
The US Justice Department is treating the mass shooting in Texas a case of domestic terrorism, with the officials seeking the death penalty for the perpetrator.
El Paso District Attorney Jaime Esparza said during a news conference that the gunman was booked on capital murder charges and prosecutors would seek the death penalty.
US President Donald Trump has ordered flags to be lowered to half-staff to acknowledge the domestic terrorist attacks in the states of Texas and Ohio. The flags will be also lowered at half-staff at all United States embassies, consular offices, and other facilities abroad, including all military facilities and naval vessels and stations.