Media playback is unsupported on your device Media caption Donald Trump spoke to reporters before boarding Air Force One

A shooting at a supermarket in the US state of Texas that left 20 dead is being investigated as domestic terrorism, officials say.

A 21-year-old white man was arrested at the scene of the attack in the city of El Paso, near the US-Mexico border.

He is believed to have posted an online document calling the attack a response to "the Hispanic invasion of Texas".

Police on Sunday said he had been charged with capital murder, meaning he could face the death penalty.

US President Donald Trump has said "perhaps more has to be done" to prevent mass shootings following the El Paso attack and another in Ohio 13 hours later in which nine people, including the gunman's sister, were killed.

"Hate has no place in our country, and we are going to take care of it," he told reporters on Sunday. "This has been going on for years, for years and years in our country and we have to get it stopped."

The president went on to link both attacks to a "mental illness problem".

"If you look at both of these cases, this is mental illness. These are people who are very, very seriously mentally ill," he said.

But critics argue that the roots of the two massacres lie in the president's language about immigrants and Mexicans in particular, and his opposition to gun control.

The El Paso gunman opened fire on a crowded Walmart on Saturday with an assault-style rifle and surrendered after being confronted by police officers outside the store. Twenty-six people were injured in the shooting.

Media playback is unsupported on your device Media caption Police were filmed responding to the shootings

"We're treating this as a domestic terrorist case," John Bash, the US Attorney for the Western District of Texas, told a news conference on Sunday.

He said the attack appeared "to be designed to intimidate a civilian population, to say the least".

The suspect has been named by US media as Patrick Crusius, a resident of Allen, in the Dallas area, about 650 miles (1,046km) east of El Paso. It is not yet clear how long before the attack he had gone to the city.

He is believed to be the author of a text posted on 8chan, an online message board frequently used by the far right, which describes a "cultural and ethnic replacement brought on by an invasion" in alluding to Hispanic people in the US.

The four-page document, reportedly posted some 20 minutes before police received the first emergency call from the Walmart, also expresses support for the gunman who killed 51 people in Christchurch, New Zealand, in March.

He has been co-operating with investigators, according to police, and has reportedly told them he acted alone.

The attack

The shooting, believed to be the eighth deadliest in modern US history, took place in a city where most of the population of 680,000 is of Hispanic descent.

The victims have not yet been named but Mexico's President Andrés Manuel López Obrador said six Mexican nationals were among the dead and seven others were injured.

Security camera images said to be of the attacker show an armed man in a dark T-shirt wearing eye glasses and what appear to be ear protectors.

Image copyright AFP Image caption Footage of the gunman was filmed by security cameras

Reports of an active shooter were received at 10:39 local time (16:39 GMT), and law enforcement officers were on the scene within six minutes, police said.

The Walmart, near the Cielo Vista Mall, was full of shoppers buying back-to-school supplies at the time of the shooting, and witnesses described scenes of chaos as customers fled for their lives.

"People were panicking and running, saying that there was a shooter," Kianna Long told Reuters news agency. "They were running close to the floor, people were dropping on the floor."

Ms Long said she and her husband ran through a stock room before taking cover with other customers.

'They're targeting us'

By Lauren Turner, BBC News, El Paso

"Yesterday I was in shock. Today, my heart is hurting."

Gilda Baeza Ortega is looking at the Walmart building in disbelief from across a car park. She had been on the way to the store, but then decided to go for breakfast with her parents instead.

But it is not just that that makes her feel so close to what has happened.

"It's the fact he was targeting us. I'm a Mexican-American and very proud of that. To me that is the biggest wound."

People have been coming here all day to lay flowers, a cross, even a Rubik's cube, in tribute.

Some are also asking police when they can retrieve their cars from Walmart's car park. It is a popular place for people to come shopping from Mexico, and many now cannot make the return journey as their passports are locked in their vehicles.

Everyone talks of what a friendly place El Paso is, how everyone knows each other. A taxi driver mentions the "six degrees of separation" here. She is dreading the list of names coming out, worried she knows one of the victims.

The reaction

Democratic presidential candidate Beto O'Rourke, an El Paso native, told CNN that Mr Trump's anti-immigrant rhetoric had stoked divisions: "He's an open avowed racist and is encouraging more racism in this country."

Also on CNN, New Jersey Senator Cory Booker, another Democratic presidential hopeful, said: "Donald Trump is responsible for this. He is responsible because he is stoking fears and hatred and bigotry."

But acting White House chief of staff Mick Mulvaney rejected the Democrats' allegations and attributed the attacks to "sick" individuals, saying on ABC: "There's no benefit here in trying to make this a political issue, this is a social issue and we need to address it as that."

Media playback is unsupported on your device Media caption After the Las Vegas attack in October 2017 the BBC looked at how US mass shootings are getting worse

Mr Trump, who has made curbing illegal immigration one of the key points of his presidency, has previously made derogatory comments about Mexican migrants and has called large groups of migrants trying to reach the US an "invasion".

In recent weeks, Mr Trump has been accused of racism after his attacks on members of Congress who are members of racial or ethnic minorities.

Mexican Foreign Minister Marcelo Ebrard said his government planned to seek legal measures to protect Mexicans and Mexican-Americans in the US.

Speaking at a news conference on Sunday, Mr Ebrard said the attorney general was considering litigation claiming that terrorism was committed against Mexicans in the shooting. Such an action could lead to the extradition of the gunman, he said.

"For Mexico, this individual is a terrorist," he told reporters.

Growing far-right violence

By Gordon Corera, BBC security correspondent

The El Paso shooting fits a growing and disturbing trend of far-right violence internationally.

Like the attack in Christchurch, the suspected attacker fits a particular profile - an individual who may have acted alone but who inhabited an international online subculture of extremism, one in which others incite and encourage violent acts.

A document which authorities have linked to the attacker was posted online and was characteristic in its claims about population replacement (in New Zealand it was Muslims, in El Paso, Hispanics).

And again, as in Christchurch, just before he acted the individual allegedly posted his intentions on the online forum 8chan. The pressure may grow now to act against such platforms and also for the authorities to take this growing threat more seriously, especially in the US.

Did you witness what happened? If it is safe to do so please email haveyoursay@bbc.co.uk

Please include a contact number if you are willing to speak to a BBC journalist. You can also contact us in the following ways: