A newly hired teacher confronted a gunman and was being hailed as a hero on Saturday after a deadly shooting rampage in the cafeteria of a Washington state high school.

First-year social studies teacher Megan Silberberger intervened in the attack Friday at Marysville-Pilchuck High School, teachers union president Randy Davis said.

The teacher intercepted the gunman as he paused, possibly to reload, student Erick Cervantes told KIRO-TV.

"I'm completely amazed by her actions and I feel for her," Davis told The Associated Press. "I don't know why she was in the cafeteria but I'm just grateful she was there."

The attacker, identified as Jaylen Fryberg, a freshman at the school, killed one girl on Friday and seriously wounded four others — including two of his cousins — before he died of what police said was a self-inflicted wound.

Washington State School Shooting

Student Jaylen Fryberg, identified as the shooter, is seen during a homecoming celebration at Marysville-Pilchuck High School on Oct. 17 in this still frame made from video. (Jim McGauhey/Associated Press)

However, it wasn't clear if the shooter committed suicide or if he accidentally shot himself in the struggle with the teacher.

A school resource officer also ran to the scene, Davis said.

Authorities were seeking a motive Saturday for what may have led Fryberg to carry out the attack. 

Fryberg was reported to be a homecoming prince and was described by both classmates and parents as a popular member of both the wrestling and football teams. He reportedly comes from a prominent family of the Tulalip Indian tribes. 

Davis said he had spoken briefly with Silberberger, who was traumatized. The Marysville School District released a statement from her.

"While I am thankful and grateful for the support from everyone, at this time I am requesting privacy for myself and my family," Silberberger said.

The incident was the latest in a series of deadly shooting rampages at U.S. schools that have played a central role in a national debate over gun laws.

Students said the gunman stared at his victims as he fired. The shootings set off chaos as students ran outside in a frantic dash to safety, while others huddled inside classrooms.

"He came up from behind and had a gun in his hand and he fired about eight bullets. They were his friends so it wasn't just random," student Jordan Luton told CNN.

"Then he turned and looked at me and my girlfriend and kind of gave us a smirk and turned around and then shot more bullets outside," Luton said.

Boys shot in head, jaw

Three of the victims had head wounds and were in critical condition Saturday. Two 14-year-old girls were at Providence Everett Medical Center, and were identified by the facility as Shaylee Chucklenaskit and Gia Soriano. Andrew Fryberg, 15, was at Harborview Medical Center in Seattle, a hospital official said.

Another victim, 14-year-old Nate Hatch, was listed in serious condition at Harborview, the hospital said. Family members told KIRO-TV that Andrew Fryberg, Hatch and Jaylen Fryberg are cousins. Two other students were treated at the high school for minor wounds, authorities said.

USA-WASHINGTON/SHOOTING

Students and family members gather at Shoultes Gospel Hall church after Friday's shooting at Marysville-Pilchuck High School in Marysville, Washington. (Jason Redmond/Reuters)

Police would not identify or discuss possible motives for the shooting, citing the ongoing investigation.

But a school official and several witnesses said he had been involved in a fight with another student.

At Marysville's The Grove Church, hundreds of parents, students and community members packed the aisles during a vigil on Friday evening, holding flowers and crying throughout a prayer service.

Outside the vigil, 9th grader Bella Panjeli said she attended a different school but was friends with one of the female victims, calling her "a beautiful girl and so, so sweet."

Rumour of dispute with cousin

She also said Fryberg was in an ongoing dispute with his cousin over the victim's affections.

"I heard he asked her out and she rebuffed him and was with his cousin," Panjeli said, adding that she learned of the connection after talking to the victim's family and friends. "It was a fight over a girl."

Washington School Shooting

After their scheduled game against Marysville-Pilchuck was cancelled, members of the Oak Harbor football team assembled at a church vigil to honour victims of the shooting. (Ian Terry/The Herald/Associated Press)

Two parents of students at the school said an altercation broke out on an athletic field following football practice in recent days, adding that one boy involved was among those shot.

Students who knew Fryberg described him as outgoing and unlike the loner personality that is often associated with school shootings.

There were no indications on his social media accounts that he had been planning such a rampage, but on Tuesday he posted his feelings of despondency, apparently over a romantic split, on Twitter.

"It breaks me ... It actually does ... I know it seems like I'm sweating it off ... But I'm not. And I never will be able to," he wrote.

His final Tweet, on Thursday said, "It won't last ... It'll never last..."

Police would not say what kind of weapon Fryberg had used, but an Alcohol, Tobacco, Firearms and Explosives official told reporters the gun had been legally acquired. U.S. media reported the weapon was a .40-caliber Beretta handgun.

Google Map: Marysville, Wash.

With files from Reuters