The death toll in a mass shooting at a Walmart in El Paso, Texas, rose to 22 people on Monday after two victims died in hospital.
The tragedy, along with another mass shooting in Ohio that killed nine, prompted US President Donald Trump to condemn white supremacy, something he had been reluctant to do in the past.
Texas prosecutors charged Patrick Crusius, 21, with capital murder for the killings in the heavily Hispanic border city of El Paso.
Texas Governor Greg Abbott said Saturday’s rampage appeared to be a hate crime and federal prosecutors called it domestic terrorism.
Police said an anti-immigrant rant posted online shortly before the shooting, which they attributed to Crusius, was evidence that the attack was racially motivated.
A Texas prosecutor said the state would seek the death penalty against him.
It was the second of three US shooting rampages in a week.
“In one voice, our nation must condemn racism, bigotry and white supremacy,” Mr Trump said from the White House.
He called the gunman "wicked” and blamed the internet and violent video games for fostering violence.
“It is too easy today for troubled youth to surround themselves with a culture that celebrates violence,” Mr Trump said.
His comments came a day after Democratic candidates for next year’s presidential election called for stricter gun laws and accused the president of stoking racial hatred.
US gun control advocates say video games are popular in many other countries where mass shootings are virtually unknown, partly because it is much harder to get a gun than it is in America.
Mr Trump proposed ways to stop those deemed to have certain forms of mental illness or who could be a risk to public safety from having access to guns.
The single murder charge against Crusius is probably to keep him in custody until further charges can be filed for each of the dead and the wounded.
His grandparents, with whom he had recently been living, said they were devastated by the attack.
“He lived with us in our house in Allen, Texas, while he attended Collin College,” they said in a statement read out by a family friend on Sunday.
“He moved out of our house six weeks ago and has spent a few nights here while we were out of town.”
It was unclear if Crusius has a lawyer or when a bond hearing or other court appearances will occur.
The FBI said on Sunday that the attack “underscores the continued threat posed by domestic, violent extremists and perpetrators of hate crimes".
It said it remained concerned that more extremists could become inspired by these and other high-profile attacks to launch their own.
The US attorney for the western district of Texas, John Bash, said federal authorities were treating the El Paso massacre as a case of domestic terrorism.
“And we’re going to do what we do to terrorists in this country, which is to deliver swift and certain justice,” Mr Bash said on Sunday.
He said the attack appeared “to be designed to intimidate a civilian population, to say the least".
FBI Director Christopher Wray told a congressional panel on July 23 that the bureau has recorded about 100 arrests of terrorism suspects in the preceding nine months and that most involved some form of white supremacy.
Thirteen hours after the Texas rampage, a gunman in body armour and a mask killed nine people in less than a minute in Dayton, Ohio, and wounded 27 before he was shot dead by police.
The attacks came a week after a man shot dead three people at a California garlic festival, before he was killed by police.
Mr Trump has often derided asylum seekers and other immigrants coming across the US southern border as liars and criminals.
At a political rally he held in May, after asking the crowd what could be done about immigrants coming in illegally, he smiled and joked after someone in the crowd yelled back: “Shoot them.”
El Paso Police Chief Greg Allen said the suspect was co-operating with investigators.
“He basically didn’t hold anything back,” Mr Allen said.
Police said the suspect opened fire with a rifle on shoppers, many of them looking for bargains on back-to-school supplies, then surrendered to officers who confronted him outside the store.
Crusius comes from Allen, Texas, a Dallas suburb about 1,046 kilometres east of El Paso, which lies along the Rio Grande across the US-Mexico border from Ciudad Juarez.
His four-page statement posted on 8chan, an online message board often used by extremists, called the Walmart attack “a response to the Hispanic invasion of Texas".
It also expressed support for the gunman who killed 51 people at two mosques in Christchurch, New Zealand, in March.
El Paso, Ciudad Juarez and Las Cruces, New Mexico, form a metropolitan border area of about 2.5 million residents, which is the largest bilingual, bi-national population in North America.