Dayton deputy police chief Lieutenant Colonel Matt Carper said police were working to identify the shooter and the FBI were on the scene.
"Fortunately we had multiple officers in the immediate vicinity when this incident started so there was a very short timeline of violence, for that we've very fortunate," he said, praising the swift response by officers.
"As bad as this is, it could have been much, much worse."
Carper said the attack appeared to be the work of a lone shooter.
The incident came just hours after the mass shooting at a Walmart store in Texas which has reignited debate about the US epidemic of gun violence.
President Donald Trump described the El Paso attack as "an act of cowardice" and police are treating it as a possible hate crime.
One suspect was taken into custody while authorities were studying an extremist manifesto purportedly written by the gunman.
Footage shot with cellphones appeared to show multiple bodies lying on the ground in the store's parking lot while other footage showed terrified shoppers running out of the store as gunfire echoed.
Two to 82 years
Police chief Greg Allen confirmed that in addition to the 20 confirmed fatalities in El Paso, there were 26 wounded.
Mexican President Andres Manuel Lopez Obrador said three Mexican citizens were killed and Foreign Minister Marcelo Ebrard said six others were wounded.
News reports said the ages of victims being treated at hospitals ranged from two to 82 years.
Police said that Walmart was "at capacity" at the time of the shooting, with 1,000-3,000 customers inside.
A 21-year-old from Allen, Texas, was the only person in custody, police confirmed. US media identified him as Patrick Crusius, who is white. He surrendered to police about a block away from the Walmart.
"Right now we have a manifesto from this individual that indicates to some degree, it has a nexus to potential hate crime," Allen said.
The "manifesto" purportedly written by Crusius that was circulated online includes passages railing against the "Hispanic invasion" of Texas and the author makes clear that he expected to be killed during his attack.
Witnesses said the gunman appeared to be shooting at random when he opened fire around 10:30 am.
One woman, who gave her name as Vanessa, said she had just pulled into the Walmart parking lot when the shooting began.
"You could hear the pops, one right after another and at that point as I was turning, I saw a lady, seemed she was coming out of Walmart, headed to her car. She had her groceries in her cart and I saw her just fall," she told Fox News.
The witness said the gunman wore a black T-shirt, combat trousers and earmuffs.
"He was just shooting randomly. It wasn't to any particular person. It was any that would cross paths."
Another shopper described how he managed to avoid being hit by hiding along with his mother between two vending machines just outside the store.
"That's where the individual tried to shoot at me, which he missed cause I kind of ducked down," Robert Curado told the El Paso Times.
"He had an AK-47."
'Act of cowardice'
Video captured by a witness in the parking lot in the immediate aftermath of the shooting showed three people lying motionless on the ground.
One had fallen next to a truck, while two were on the sidewalk outside the store entrance.
"Ambulance! Help!" people cried as they rushed to the victims.
A still captured from CCTV showed the gunman carrying what appeared to be an AK-47 assault rifle.
Beto O'Rourke, a former US congressman for El Paso who is now running for president, cut off his campaigning in the wake of the shooting.
"I'm incredibly saddened and it's very hard to think about this. But I tell you El Paso is the strongest place in the world, this community is going to come together," he told supporters.
Elizabeth Warren, a senator who is among the frontrunners for the Democratic party's presidential nomination, said: "We must act now to end our country's gun violence epidemic."
This story has been published from a wire agency feed without modifications to the text. Only the headline has been changed.
Subscribe to Mint Newsletters
* Enter a valid email
* Thank you for subscribing to our newsletter.
Never miss a story! Stay connected and informed with Mint.
our App Now!!