A school custodian stopped a suspect from continuing a shooting rampage that killed one student and injured three others at a high school near Spokane, Wash., authorities said Wednesday.

The Spokane County Sheriff's Office said Wednesday evening that the custodian approached the suspect at Freeman High School during the incident that morning and ordered him to surrender.

The suspect brought two weapons to the school in Rockford, south of Spokane, but the first one he tried to fire jammed, Spokane County Sheriff Ozzie Knezovich told reporters.

"He went to his next weapon," Knezovich said. "A student walked up to him, engaged him, and that student was shot. That student did not survive."

spokane shooting (2)

Ambulances line up outside Sacred Heart Hospital following reports of a shooting in Rockford, Wash., Sept. 13, 2017. (Kathy Plonka/The Spokesman-Review via Associated Press)

The sheriff said the suspect fired more rounds down the hallway, striking the other students, before the custodian intervened, Knezovich said.

He added that the janitor's actions were a courageous act that prevented further bloodshed.

A Spokane County deputy who works as a school resource officer arrived shortly thereafter and took the suspect into custody.

The three victims who survived were all stable and doing well, officials said, although one was expected to need surgery later Wednesday. No information on specific injuries was provided. None of the three victims was identified.

A two-lane road into the town of about 500 people near the Idaho border was clogged as worried parents sped to the school. Some people abandoned their cars on the street to get to their children.

Cheryl Moser said her son, a freshman, called her from a classroom after hearing shots fired.

spokane shooting (5)

The sign for Freeman High School in Rockford, Wash., is seen outside the campus, Sept. 13, 2017. (Associated Press)

"He called me and said, 'Mom, there are gunshots.' He sounded so scared. I've never heard him like that," Moser told the Spokesman Review of Spokane. "You never think about something happening like this at a small school."

Michael Harper, a 15-year-old sophomore student at Freeman, told the Associated Press that the suspect had long been obsessed with past school shootings. He said he saw the student at school with a duffel bag and that the suspect had brought notes to school in the beginning of the year, saying he might get killed or jailed. Harper said some students alerted counselors.

Harper said the suspect had many friends and was not bullied, calling him "nice and funny and weird" and a huge fan of the TV show "Breaking Bad."

Witnesses said the suspect rode the schools bus Wednesday morning with a pistol and rifle stashed in his duffel bag, the Spokesman-Review reported.

Knezovich said at the afternoon news conference that the suspect, whom he declined to identify, had no apparent accomplices and was being held in the county’s juvenile detention center.

“It sounds like a case of a bullying type of situation,” he said at the news conference, without elaborating.

The Associated Press contributed to this story.