The 21-year-old gunman who killed two students before allegedly committing suicide inside a New Mexico high school Thursday disguised himself as a student to get inside, law enforcement officials said.

San Juan County Sheriff Ken Christesen said Friday that the gunman, identified as William Atchison, entered Aztec High School around 8:00 a.m. local time with a backpack and a .9mm Glock with multiple magazines on him. He was a former student at the high school.

Christesen called the shooting a cowardly act and said Atchison was determined to create as much carnage as he could.

“This was a planned event,” he said, adding the gun used in the shooting was purchased legally. "This person is not only a coward, he's evil."

He added: “It's important to understand how focused he was, how deranged he was, in his intent.”

State Police Chief Pete Kassetas said Atchison’s first victim was Francisco I. Fernandez, who had excused himself from class to go to the bathroom and was immediately shot.

Kassetas said Atchison then walked into the hallway, encountered Casey J. Marquez and killed her. Atchison then walked up and down the hallway, firing randomly and into classrooms.

Officials said they believe Atchison eventually shot himself. They said the students killed were not targeted, but were at the "wrong place at the wrong time."

Christesen said there were heroes at the school that helped save lives on Thursday. He said a substitute teacher heard the gunshots but didn’t have a key to lock the door to the computer lab. So instead she took students into an office or storage area and barricaded the door.

Atchison, who was from Aztex and worked at a local gas station, went into the room and yelled that he knew they were in there and then fired multiple shots into the room. A custodian also heard the gunshots and yelled for classrooms to lock their doors.

"Their swift action saved a whole lot of lives and a lot of devastation," Christesen said.

Authorities said they also found a message in which Atchison wrote that work, school and life were bad and he wanted out. It also included a timeline of what he had planned for that day.

Part of the message said: “Work, packup, prep, walk, die.”

Christesen said they also found a thumb drive on Atchison that had electronic notes that could provide more insight into the attack. He said it has been given to the FBI for investigation.

The FBI says it investigated the New Mexico school shooter last year about online comments, though he said he had no plans for an attack at the time.

Terry Wade, FBI special agent in charge in Albuquerque, said Atchison made generic comments in a gaming forum and that he and his family were interviewed in March 2016.

"It was determined no crime was committed," he said, adding the investigation was closed

The shooting has rocked Aztec, a community of about 6,500 near the Colorado border. Hundreds gathered for prayer services and candlelight vigils and more gatherings are planned over the weekend as residents look for answers.

New Mexico Gov. Susana Martinez said she spent the evening with the families of the victims and said it was “amazing to see the unity from grownups, teachers, pastors, and to see unification of the community.”

“Healing is beginning,” she said, adding the state would cover the costs of the students' funeral services.

Two GoFundMe pages have been created to help Fernandez and Marquez’s families.

The Associated Press contributed to this report.