The 18-year-old suspect, who was killed apparently by police, also had shot his own grandmother before fleeing from the scene.
Family members of the victims in tears
A teenager has killed 19 children after storming his school in the Texas areas of the United States.
The killer wore a body armour and also killed two adults after storming into a Texas junior school on Tuesday.
The 18-year-old suspect, who was killed apparently by police, also had shot his own grandmother before fleeing from the scene, then crashing his getaway car and launching a bloody rampage at Robb Elementary School in the town of Uvalde, Texas, about 80 miles (130km) west of San Antonio.
The motive was not immediately clear.
Law enforcement officers saw the gunman, clad in body armour, emerge from his crashed vehicle carrying a rifle and “engaged” the suspect, who nevertheless managed to charge into the school and open fire, Texas Department of Public Safety (DPS) Sergeant Erick Estrada said on CNN.
Speaking from the White House hours later, a visibly shaken US President Joe Biden urged Americans to stand up to the politically powerful US gun lobby, which he blamed for blocking enactment of tougher “common-sense” firearms safety laws.
Biden ordered flags flown at half-staff daily until sunset on Saturday in observance of the tragedy.
Governor Greg Abbott said that the suspect, identified as Salvador Ramos, was apparently killed by police officers, and that two officers were struck by gunfire, though the governor said their injuries were not serious.
Authorities said the suspect acted alone. He had also killed his grandmother before storming the school.