The attack unfolded at Robb Elementary School in Uvalde, a small Hill Country town with a population of just more than 16,000, late on Tuesday morning.
The 18-year-old suspect, identified as Salvador Ramos, reportedly bought two rifles legally just days after his birthday last week, it has emerged.
Investigators said the suspect had a handgun, an AR-15 semi-automatic rifle and high-capacity magazines.
The weapon’s popularity has been growing since 2004, when a ban on federal assault weapons in the US expired.
One of out of every five firearms purchased in the US today is an AR-style rifle, according to estimates by the National Shooting Sports Foundation (NSSF), a national trade association for the firearm industry.
The gun is said to be desirable among Americans because of its versatility, with the ability to add scopes and change the length and size of the barrel.
The semi-automatic weapon fires one round for each pull of the trigger.
The AR-15 was developed in the late 1950s as a civilian weapon by a former Marine working for a small California start-up company called ArmaLite.
By October 2021, the United States had more than 20 million AR-15-style rifles legally in circulation, the NSSF told ABC News.
An AR-15 semi-automatic rifle or variant has reportedly been used in multiple mass shootings in recent years, including the Sandy Hook, San Bernadino and Las Vegas shootings.
On Tuesday, the suspect first shot his own grandmother, who survived, authorities said.
He then fled that scene and crashed his car near Robb Elementary School where he launched the bloody rampage that ended when he was killed, apparently shot by police.
Police saw the gunman, clad in body armour, emerge from the crashed vehicle carrying a rifle and “engaged” the suspect but he managed to charge into the building and open fire, Texas Department of Public Safety (DPS) Sergeant Erick Estrada said on CNN.
Eva Mireles, 44, and Irma Garcia, who was in her forties, have been named by their families as the two teachers killed in the attack on Robb Elementary School.
The identities of the 19 child victims are also emerging. Uziyah Garcia, 9, Amerie Jo Garza, Makenna Lee Elrod, Xavier Javier Lopez, Jose Flores, Navaeh Brown, Annabell Guadalupe Rodriguez and Ellie Lugo, all aged 10 are among those named so far.
This latest attack has echoes of the 2012 Sandy Hook shooting which saw 2 killed at a school in Newtown, Connecticut.
On 14 December 2012, 20-year-old Adam Lanza fatally shot his mother at their Newtown home before going to Sandy Hook Elementary School.
He shot his way into the locked school where he killed 20 first graders and six educators with an AR-15-type rifle purchased legally by his mother. He then killed himself before police arrived.
In February, the families of nine Sandy Hook victims reached a $73 million settlement in a lawsuit against the maker of the rifle used in the shooting.
The case against Remington, filed in 2015, was closely watched by gun control advocates, gun rights supporters and manufacturers because of its potential to provide a road map for victims of other shootings to sue firearm makers.
The families and a survivor argued the company should have never sold such a dangerous weapon to the public.
They’ve said their focus is on preventing future mass shootings by forcing gun companies to be more responsible with their products and how they market them.
On 14 February 2018 a gunman similarly used an AR-15-style rifle to kill 14 children and three staff members at Marjory Stoneman Douglas High School in Parkland, Florida.
Speaking from the White House on Tuesday, a visibly shaken president Joe Biden urged Americans to stand up to the politically powerful gun lobby, which he blamed for blocking enactment of tougher firearms safety laws.
Mr Biden ordered flags flown at half-staff daily until sunset on Saturday in observance of the tragedy.
“As a nation, we have to ask, ‘When in God’s name are we going to stand up to the gun lobby?’,” the leader said on national television, suggesting reinstating a US ban on assault-style weapons and other “common sense gun laws.”
Additional reporting by Reuters