Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A disgruntled student armed with several weapons opened fire at a Washington state high school Wednesday, killing a classmate who tried to reason with him and wounding three others before he was captured, police said.

And the death toll at Freeman High School south of Spokane might have been even higher if the shooter's first weapon hadn't jammed at the outset, Spokane County Sheriff Ozzie Knezovich said.

"This would have been a lot worse if it didn't," he said. "That student came to school armed. He entered the school. He proceeded to take his weapons out. At that point he attempted to fire one weapon, it jammed. He went to his next weapon."

Knezovich did not identify the gunman or the brave student who tried to engage the shooter when his first gun jammed.

"It sounds like he tried to walk up and tell him, 'I'm not, this isn't what you want to do'," the sheriff said.

But the armed student wasn't swayed by those words and shot him.

"He then fired more rounds down the hallway, striking three more students and those students are in the hospital right now in serious condition," the sheriff said.

Knezovich did not go into detail about how the rampage at the school in the town of Rockford ended, but he credited "some fairly courageous action by a member of the Freeman School staff."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"This is another example of somebody that had a lot of courage, stepped up and stopped this before it got worse," he said.

The sheriff's department later said that after the shooting a school custodian approached the shooter and ordered him to surrender, and a deputy who had been at a nearby middle school arrived and took the alleged shooter into custody.

Asked for a motive, Knezovich said "it sounds like a case of a bullying type of situation."

"These are senseless and tragic events that really don't need to happen and I don't understand them," he said. "I don't think anybody can make any sense out of this but we need to figure out what's gone wrong with our society that our children decide that they need to take weapons to deal with the issues that they're facing."

The suspect was in a juvenile lockup and had not yet been charged with a crime, officials said.

Spokane County Sheriff's vehicles and an ambulance outside Freeman High School in Spokane, Washington. KHQ TV

Over at Providence Sacred Heart Medical Center & Children's Hospital in nearby Spokane, the chief of surgery said he expects all three victims will recover.

"We have three teenagers with us and they are all doing well, they're stable at this point," said Dr. Mike Moore said. "One will be requiring some surgery later this afternoon."

Both the FBI and the ATF have dispatched investigators to the scene to help with the investigation.

"Typically, that could be as straightforward as additional manpower but we are also poised to offer specialized resources if needed," and FBI spokeswoman told NBC News.

Meanwhile, school is canceled Friday.

"This morning's shooting at Freeman High School is heartbreaking," Gov. Jay Inslee said in a statement. "As Spokane County officials continue their investigation to get the answers to the questions so many of us have during these unthinkable tragedies, the Washington State Patrol and all state agencies will do whatever we can to help provide support and comfort in the days and weeks to come."