(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 Texas announced 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.

Read More