In Texas, where a mass shooting this weekend in El Paso left 22 dead, another potential one was thwarted last month when a woman convinced her grandson to visit a hospital for treatment instead of opening fire at a hotel as he'd planned.

William Patrick Williams, 19, of Lubbock, was arrested by federal authorities on Thursday after a short hospitalization.

“This was a tragedy averted,” Nealy Cox, the U.S. attorney for the Northern District of Texas, said in a statement. "I want to praise the defendant’s grandmother, who saved lives by interrupting this plot."

VICTIMS OF EL PASO SHOOTING INCLUDED MOTHER SHIELDING SON FROM BULLETS, TEEN ABOUT TO START SOPHOMORE YEAR OF HIGH SCHOOL

Investigators said William Patrick Williams was planning a mass shooting at a hotel. (Lubbock County Jail via AP)

Williams told his grandmother he purchased an AK-47 rifle and planned to "shoot up" a local hotel and commit suicide by cop, federal prosecutors said last week. The woman convinced him to let her bring him to a hospital instead.

She gave authorities consent to search a room Williams rented at the hotel. Officers found the rifle, 17 magazines loaded with ammunition, several knives, a black trench coat, tactical pants, a T-shirt that read "Let 'Em Come" and black gloves with the fingers cut off.

A check of the form used to purchase the weapon found Williams listed false information, including his address. He was arrested for allegedly making false statements to a firearms dealer.

CLICK HERE TO GET THE FOX NEWS APP

He faces up to five years in prison.

The arrest came mere days before another a gunman walked into an El Paso Walmart on Saturday and opened fire. So far, the shooting's death toll is 22, with many more injured.

A few hours later, another gunman killed nine people in a separate spree in Dayton, Ohio.