Two mass shootings in the US have left 29 people dead within 24 hours, the latest such attacks in a nation torn over how to tackle gun violence.

A gunman armed with an assault rifle killed 20 people on Saturday when he opened fire on shoppers at a packed Walmart store in El Paso, Texas.

Less than 13 hours later, a lone shooter killed nine people in Dayton, Ohio early on Sunday before being shot dead by responding police officers.

“We have nine victims deceased . . . and we have approximately 16 more victims hospitalised right now in unknown conditions,” Dayton Police Lieutenant Colonel Matt Carper said.

The attacker opened fire at around 1am Sunday (11am Cambodian time) on a street in the popular bar and nightlife Oregon district.

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’re 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 investigation would continue through the night but 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.

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.

Various 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.”

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.”