The Texas gunman who murdered 19 children and two teachers posted on social media that he was going to shoot up an elementary school about 15 minutes before his rampage, the state’s Governor Greg Abbott says, as harrowing details about the attack continued to emerge.

The gunman, identified as 18-year-old Salvador Ramos, also wrote a message saying he was going to shoot his grandmother and another one confirming he had done so, Abbott said at a news conference. His grandmother, whom Ramos shot in the face shortly before attacking the school, survived and called police.

Ramos fled the home he shared with his grandmother and crashed his car near Robb Elementary School in Uvalde, Texas. He entered the school through a back door carrying an AR-15 assault-style rifle and wearing tactical gear.

He barricaded himself in a fourth-grade classroom, authorities said, and killed students and teachers before he was fatally shot by a US Border Patrol officer, Abbott said. An additional 17 people suffered non-life-threatening injuries.

The online messages were the only advance warning, Abbott said, adding that Ramos, a high school dropout, did not appear to have any criminal record or history of mental health problems.

Abbott said the posts were made on Facebook, but spokespeople for Facebook’s parent company, Meta Platforms , said they were private messages discovered after the shooting. The company declined to say who received the messages or which of Meta’s platforms, such as Messenger or Instagram, was used to send them.

Ramos purchased two rifles and 375 rounds of ammunition in March, according to authorities.

The attack, which came 10 days after an avowed white supremacist shot 13 people at a supermarket in a mostly black neighbourhood of Buffalo, has reignited a national debate over US gun laws.

In a sign of the charged political atmosphere, Beto O’Rourke, the Democratic candidate challenging Abbott in a November election, interrupted the news conference to confront Abbott for loosening, rather than restricting, the state’s gun laws.

Texas has some of the country’s most permissive firearm laws.

In a prime-time address on Tuesday evening, President Joe Biden called for new gun safety restrictions.

“As a nation, we have to ask when in God’s name we’re going to stand up to the gun lobby,” he said, his voice rising.

But new legislation appeared unlikely to pass in Washington. Virtually all Republicans in Congress oppose new gun restrictions, citing the US Constitution’s guarantee of a right to bear arms, and there was no sign the massacre would alter that position.

White House officials were planning a trip to Texas for Biden, a senior administration official said.

World leaders expressed shock and sympathy. Pope Francis on Wednesday said he was “heartbroken” and called for an end to “the indiscriminate trafficking of weapons.”

The Texas rampage stands as the deadliest US school shooting since a gunman killed 26 people, including 20 children, at Sandy Hook Elementary School in Connecticut in December 2012.

Community members set up fundraisers for the families of the victims to cover funeral costs, while some relatives mourned their losses on social media.

“My little love is now flying high with the angels above,” Angel Garza, whose daughter, Amerie Jo Garza, was killed, wrote on Facebook. “Please don’t take a second for granted. Hug your family. Tell them you love them.”