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".
US President Donald Trump has said "perhaps more has to be done" to prevent mass shootings.
"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 the El Paso attack and another shooting in Ohio 13 hours later, which left nine dead, 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.
The El Paso gunman opened fire on a crowded Walmart with an assault-style rifle and surrendered after being confronted by police officers outside the store. Saturday morning's attack also left 26 people injured.
"We're treating this as a domestic terrorist case," John Bash, the US Attorney for the Western District of Texas, told a news conference.
He said the attack appeared "to be designed to intimidate a civilian population, to say the least".
As well as 20 counts of murder, the suspect, named by US media as Patrick Crusius, could face federal hate crime and firearms charges.
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.
Police confirmed that the suspect lived in 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 has been co-operating with investigators, according to police, and has reportedly told them he acted alone.