A US student who had issued chilling warnings on Twitter opened fire in a school cafeteria on Friday, killing at least one person and critically injuring three before taking his own life.

Terrified classmates dived for cover as the gunman, identified by media reports and fellow students as Jaylen Fryberg, launched his attack in a school in the northwestern state of Washington.

Police said the investigation was still ongoing and would likely continue into the early morning Saturday.

"This continues to be an active homicide investigation. We want to make sure we do this right and have all of the right answers," local police spokesman Robb Lamoureux told a press conference late Friday.

As with previous such shootings, the episode revived debate on gun control, even though the gun involved was legally acquired.

"I heard one loud bang and I was wondering what it was. Then I heard about four or five more. People started screaming and people started getting to the ground and going for the nearest exit," said a student identified as Jordan.

"So I hit the ground. But after he'd already put some bullets into the backs of students," he told CNN.

The shooting, just the latest in a long line of such rampages in the United States, erupted in Marysville, 55 kilometers north of Seattle.

Lamoureux declined to identify the shooter or comment on online suggestions, including on Fryberg's social media posts, that the attack might have been triggered by a failed romance.

"The shooter died of a self-inflicted gunshot wound," he said earlier in the day.

Television footage showed swarms of police descending on the Marysville-Pilchuck High School as students, some with hands on heads, came out of the sprawling campus, which has some 2,500 students.

A student identified as Austin told KING 5 television how the gunman was initially "quiet" before opening fire on fellow diners.

"There was just a big group of kids... He was quiet. He was just sitting there. Everyone was talking. All of a sudden I see him stand up, pull something out of his pocket," he said.

"At first I thought it was just someone making a really loud noise with like a bag, like a pretty loud pop until I heard four more after that, and I saw three kids just fall from the table like they were falling to the ground dead."


'Tortured Twitter posts '

Fryberg, a Native American, left a series of tortured posts on Twitter, suggesting a teenager used to handling guns, and hinting that a failed romance may have triggered the shooting.

One post on Instagram showed him brandishing a hunting rifle.

"Probably the best BirthDay present ever! I just love my parents!!!!," he posted in a message accompanying the photo.

In his final post on Twitter on Thursday, Fryberg had stated ominously: "It won't last...It'll never last...."


Earlier, in August, he had issued threats to an apparent love rival: "Your not gonna like what happens next."

But some schoolmates voiced shock after the attack by Fryberg, reportedly a popular student.

"When I saw him, I was like, oh my gosh, that's Jaylen. I would have never expected it would have been him out of all people," student Rachel Heichel said.

Joanne Roberts, a doctor at Providence Medical Center, told local TV station KOMO that three young people were in a "very critical condition" after the shooting.

Two female patients were being treated in the Providence ICU while two males were in the ICU at Harborview Medical Center, according to the Marysville Police Department, which said all were under age 18.

CNN reported that one of the boys had been critically injured, while the other was being treated for a jaw injury.

Previous mass shootings, like that which killed 20 children and six adults at an elementary school in Newtown, Connecticut in December 2012, have triggered intense debate about America's relatively lax gun control laws.

The weapon used in Friday's attack was not identified, but Doug Dawson of the Bureau of Alcohol, Tobacco, Firearms and Explosives (ATF) said that it had been "legally acquired," declining to comment further.

Marysville police chief Rick Smith said the shooting should be a wake-up call.

"It's time for us to act, and not just talk anymore," he said.