Federal agents say they were able to prevent a mass shooting here in Lubbock last week.

ATF agents arrested William Patrick Williams, 19, for lying on a background check to buy a gun.

Court records show he intended to shoot up a hotel in Lubbock and get police to kill him. Records did not show specifically which hotel.

Agents say last month Williams told his grandmother he was homicidal and suicidal. She got him to a hospital. During an exam, Williams reportedly told doctors he had bought an AK-47-style rifle and planned the attack.

Investigators searched a hotel room he'd rented. They report finding the rifle, 17 loaded magazines, a trench coach and several knives. They also found documents detailing Williams' depression and medication. According to the U.S. Attorney's Office for the Northern District of Texas, Williams laid the weapons out on the bed so law enforcement could take custody of them.

ATF agents report Williams bought the rifle under false pretenses two days earlier, by lying on the paperwork.

"This was a tragedy averted,” U.S. Attorney Nealy Cox said in a news release Friday. “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. If you suspect a friend or loved one is planning violence against themselves or others, do not hesitate to seek help immediately by calling law enforcement.”

“The safety of our citizens is paramount,” Lubbock Interim Police Chief Jerry Brewer said in the news release. “When events like this occur we greatly appreciate the cooperative relationships with our federal law enforcement partners that enhance our abilities to protect the community.” 

He is due in court this week. If convicted on the charge of lying to a federally licensed gun dealer, Williams could spend up to five years in federal prison.