US President Joe Biden has called for new restrictions on firearms in America after a gunman massacred at least 19 children at a Texas elementary school.

In an emotional address to his nation from the White House, Mr Biden pleaded for action to curb gun violence after years of failure – and blamed firearms manufacturers and their supporters for blocking legislation in Washington.

He said: “When in God’s name are we going to stand up to the gun lobby? Why are we willing to live with this carnage? Why do we keep letting this happen?”

The US leader spoke just hours after an 18-year-old gunman opened fire at Robb Elementary School in Uvalde, 85 miles west of San Antonio, killing at least 19 children and two adults.

It is America’s deadliest school shooting since 20 children and six adults died at Sandy Hook Elementary in Newtown, Connecticut, in late 2012.

The gunman – identified by officials as Salvador Ramos, who lived in the community – was killed by law enforcement responding to the massacre. Texas governor Greg Abbott said one of the two adults killed by the gunman was a teacher.

With US first lady Jill Biden standing by his side in the Roosevelt Room, the US president, who has suffered the loss of two of his own children, spoke in visceral terms about the grief being suffered by the victims’ loved ones and the pain that will endure for the students who survived.

“To lose a child is like having a piece of your soul ripped away,” Mr Biden said.

“There’s a hollowness in your chest. You feel like you’re being sucked into it and never going to be able to get out.”

He called on the nation to pray for the victims and families – but also to work harder to prevent the next tragedy. “It’s time we turned this pain into action,” he said.

Just one week earlier, Mr Biden had travelled to Buffalo in New York state to meet with victims’ families after a racist gunman killed 10 black people at a grocery store.

The back-to-back tragedies serve as sobering reminders of the frequency and brutality of an American epidemic of mass gun violence.

The Texas gunman barricaded himself inside a classroom “shooting anyone that was in his way”, an official said on Wednesday.

School shooting
The archbishop of San Antonio, Gustavo Garcia-Siller, comforts families outside the Civic Centre following a deadly school shooting at Robb Elementary School in Uvalde, Texas (AP)

Police and others responding to the attack broke windows at the school in an effort to allow students and teachers inside to escape, said Lt Christopher Olivarez of the Texas Department of Public Safety.

He said that all the victims were in the same classroom.

Families waited hours for word on their children. At the town civic centre where some gathered, the silence was broken repeatedly by screams and wailing.

Many of the wounded were rushed to Uvalde Memorial Hospital, where staff members in scrubs and devastated victims’ relatives could be seen weeping as they walked out of the complex.

It is not immediately clear how many people were wounded, but Uvalde Police chief Pete Arredondo said there were “several injuries”.

Earlier, Uvalde Memorial Hospital said 13 children were taken there. Another hospital reported a 66-year-old woman was in critical condition.

The attack on the school began about 11.30am. The gunman had already shot his grandmother, according to Lt Olivarez. After fleeing that scene, he crashed his car at the school and made his way inside.

Lt Olivarez said that when local and state officers responded they heard gunshots – and were shot at themselves.

“The shooter was able to make entry into a classroom, barricaded himself inside that classroom and again just began shooting numerous children and teachers that were in that classroom having no regard for human life… Just began shooting anyone that was in his way,” he said.

“At that point we had a tactical law enforcement arrive… that were able to able to make forcible entry into that classroom. They were met with gunfire as well but they were able to shoot and kill that suspect.”

“These kinds of mass shootings rarely happen anywhere else in the world – why?” Mr Biden asked in the White House.

The president reflected that while other nations have people filled with hate or with mental health issues, no other industrialised nation experiences gun violence at the level of the US.

“The idea that an 18-year-old kid can walk into a gun store and buy two assault weapons is just wrong,” Mr Biden said, adding: “I’d hoped when I became president I would not have to do this, again.”

Grieving people
People react outside the Civic Centre in Uvalde, Texas, following the massacre (AP)

Echoing Mr Biden’s call, former president Barack Obama, who has called the day of the Sandy Hook shooting the darkest of his administration, said: “It’s long past time for action, any kind of action.”

US congress has been unable to pass substantial gun violence legislation ever since the bipartisan effort to strengthen background checks on firearms purchases collapsed in the aftermath of the 2012 shooting.

Despite months of work, a bill that was backed by a majority of senators fell to a filibuster – unable to overcome the 60-vote threshold needed to advance.

In impassioned remarks on the US senate floor on Tuesday, senator Chris Murphy, who represented Newton, Connecticut, in the house of representatives at the time of the Sandy Hook massacre, asked his colleagues why they even bother running for office if they are going to stand by and do nothing.

He said: “I’m here on this floor to beg – to literally get down on my hands and knees – to beg my colleagues.”

Mr Murphy said he was planning to reach out to Texas Republican senator John Cornyn after the two had teamed up on an earlier background check bill that never became law. He said he would also reach out to Texas’ other Republican senator, Ted Cruz.

“I just don’t understand why people here think we’re powerless,” Mr Murphy said. “We aren’t.”

The teenage gunman had hinted on social media that an attack could be coming, according to state senator Roland Gutierrez, who said he had been briefed by state police.

He noted that Ramos “suggested the kids should watch out”, and that he had bought two “assault weapons” after turning 18.

Texas School Shooting
People leave the Uvalde Civic Centre following a shooting earlier in the day at Robb Elementary School (The San Antonio Express-News via AP)

Investigators believe Ramos posted photos on Instagram of two guns he used in the shooting, and they were examining whether he made statements online alluding to the attack in the hours before the assault, a law enforcement official said.

Officers were serving multiple search warrants on Tuesday night and gathering telephone and other records. Investigators were also attempting to contact Ramos’ relatives and were tracing the firearms.

Vigil for school shooting victims
A vigil takes place for the victims (The San Antonio Express-News via AP)

Teams of Border Patrol agents had raced to the school, including 10 to 15 members of a Swat-like tactical and counter-terrorism unit, officials said.

One Border Patrol agent who was working nearby when the shooting began rushed into the school without waiting for backup and shot and killed the gunman, who was behind a barricade.

The agent was wounded but able to walk out of the school, the law enforcement source said.