The sign for Freeman High School in Rockford, Wash., is seen outside the campus Wednesday, Sept. 13, 2017. Authorities say one student was killed and three others were injured in a shooting at the school. A suspect was taken into custody. (AP Photo/Nicholas K. Geranios).

Michael Harper, 15, a sophomore at Freeman High School, speaks to reporters Wednesday, Sept. 13, 2017, in Rockfort, Wash. Authorities say a shooter opened fire at the school, killing one and wounding three. The suspect was in custody. (AP Photos/Nicholas K. Geranios)

People hurry toward Freeman High School in Rockford, Wash., Wednesday, Sept. 13, 2017. Parents rushed to the area after a deadly shooting at the school. (AP Photo/Nicholas K. Geranios)

Cars and emergency vehicles are seen in front of Freeman High School in Rockford, Wash., Wednesday, Sept. 13, 2017. Authorities say a shooter opened fire at the school. A suspect was apprehended. (AP Photo/Nicholas K. Geranios)

Ambulances line up in the emergency area of Sacred Heart Hospital following reports of a shooting at Freeman High School on Wednesday, Sept. 13, 2017 in Rockford, Wash. A shooter opened fire at a the high school, south of Spokane, killing one student, injuring three others. The injured victims were taken to a hospital and expected to survive. Authorities say the suspect was in custody. (Kathy Plonka/The Spokesman-Review via AP)

Parents gather in the parking lot behind Freeman High School in Rockford, Wash. to wait for their kids, after a deadly shooting at the high school Wednesday, Sept. 13, 2017. (Dan Pelle/The Spokesman-Review via AP)

People gather outside of Freeman High School after reports of a shooting at the school in Rockford, Wash., Wednesday, Sept. 13, 2017. (KHQ via AP)

ROCKFORD, Wash. (AP) — A student who opened fire in a hallway at a Washington state high school killed a classmate who confronted him Wednesday and wounded three others before being stopped by a custodian, authorities said.

The suspect, who a classmate described as being obsessed with previous school shootings, was taken into custody. The wounded victims were seriously injured but expected to survive, officials said.

The shooter brought two weapons to Freeman High 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."

The sheriff said the shooter fired more rounds down the hallway, striking the other students, before a school custodian approached the shooter and ordered him to surrender, Knezovich said.

Knezovich called it a courageous act that prevented further bloodshed.

The sheriff said a deputy who works as a school resource officer arrived shortly thereafter and took the shooter into custody.

Elisa Vigil, a 14-year-old freshman, told The Associated Press that she saw one male student shot in the head who janitors covered with a cloth and another female student wounded in the back.

Michael Harper, a 15-year-old sophomore, said the suspect had brought notes in the beginning of the school year, saying he was going to do "something stupid" and might get killed or jailed. Some students alerted counselors, the teen told AP, but it wasn't clear what school officials did in response.

A call to the school was not immediately returned.

Harper said the shooter had many friends and was not bullied, calling him "nice and funny and weird" and a huge fan of the TV show "Breaking Bad." He also said the suspect was obsessed with other school shootings.

Students say the shooter was armed with a pistol and rifle and had carried a duffel bag to school. After shots were fired, students went running and screaming down the hallways, Harper said.

Authorities didn't release the suspect's identity or a possible motive. The victims also were not named.

Luis Prito, an assistant football coach at Freeman High, called the shooting devastating. A vigil took place Wednesday evening at a nearby church.

"This is a real close-knit community," he said.

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 make it to their children.

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

"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 newspaper. "You never think about something happening like this at a small school."

Providence Sacred Heart Medical Center and Children's Hospital received three pediatric patients, spokeswoman Nicole Stewart said. They were in stable condition and surrounded by family, she said.

Stephanie Lutje told AP she was relieved to hear her son was safe after his high school near Freeman High was put on lockdown. She commended the school district for its communication.

"It's been amazing, within probably 15-20 minutes of hearing about it, I'd already received a phone call, I'd already received a text message saying that their school is OK," she said.

She still worried for others she knew, including a co-worker who had yet to hear from her son, a sophomore at Freeman.

"My stomach's in knots right now," she said.

Gov. Jay Inslee said in a statement that "all Washingtonians are thinking of the victims and their families, and are grateful for the service of school staff and first responders working to keep our students safe."