(CNN) — Less than a month before two deadly shootings took the lives of 29 people in one weekend, another mass shooting was stopped.

A Lubbock, Texas man, identified as William Patrick Williams, 19, was arrested by special agents of the FBI and ATF, the US Attorney’s Office of the Northern District of Texasannounced Friday.

Williams was allegedly contemplating a mass shooting and bought ammunition. He rented a hotel room where he was plotting to kill people before his grandmother persuaded him to visit a hospital after learning of his plan, the release said.

According to the release, Williams told his grandmother on July 13 he had recently purchased an AK-47 rifle, was planning to “shoot up” a hotel and “then commit suicide by cop.”

The grandmother was able get him into treatment prior to his arrest.

Authorities applauded the courageous actions of Williams’ grandmother, saying her interference likely saved the lives of many.

“This was a tragedy averted,” said US Attorney Nealy Cox. “I want to praise the defendant’s grandmother, who saved lives by interrupting this plot, as well as the Lubbock police officers and federal agents who investigated his unlawful acquisition of a deadly weapon.”

Williams was arrested after a hospitalization and gave investigators permission to search his hotel room, the release said.

Investigators uncovered an AK-47 rifle, 17 magazines loaded with ammunition and multiple knives in Williams’ hotel room, according to the release.

Williams told officers he had laid out his weapons on a bed so that law enforcement could take custody of them.

Other items recovered from the room included a black trench coat, black tactical pants, a black T-shirt that read “Let ‘Em Come,” the press release said.

On July 21, the ATF received a firearms transaction form filled out on July 11 where Williams lied about his residence.

He has been charged with making false statements to a firearms dealer because of his claim that he lived at an address where he had been evicted. The offense carries up to five years in federal prison.

“The FBI worked closely with our partners at the ATF and Lubbock Police Department to prevent the defendant from potentially committing a violent act,” said Matthew DeSarno, special agent in charge of the FBI’s Dallas field office.

“This case is a perfect example of law enforcement agencies coming together to find a solution that protected the public from harm.”

The-CNN-Wire™ & © 2024 Cable News Network, Inc., a Time Warner Company. All rights reserved.

Join our Newsletter for the latest news right to your inbox