The student who killed two pupils at a US school on Friday invited his victims to lunch by text message, then shot them at their table.

Sheriff Ty Trenary said that five students were at a lunch table at Marysville-Pilchuck High School north of Seattle in Washington state when they were shot by 15-year-old Jaylen Fryberg. Fryberg then committed suicide.

Detectives are digging through text messages, phone and social media records as part of an investigation that could take months, Mr Trenary said.

"The question everybody wants is, 'Why?'" he said. "I don't know that the 'why' is something we can provide."

Fryberg, a football player who was named a prince on the school's Homecoming court a week before the killings, was a member of a prominent Tulalip Indian Tribes family.

He seemed happy although he was also upset about a girl, friends said. His Twitter feed was recently full of vague, anguished postings, like "It won't last ... It'll never last," and "I should have listened. ... You were right ... The whole time you were right."

On Friday, after texting five friends to invite them to lunch, he pulled out a handgun in the cafeteria and started shooting.

The victims were Zoe Galasso, 14, who died at the scene; Gia Soriano, 14, who died in hospital on Sunday night; Shaylee Chuckulnaskit, 14, who remains in a critical condition; and his two cousins, Nate Hatch, 14, and Andrew Fryberg, 15.

Andrew Fryberg also remains in a critical condition. Nate, who was shot in the jaw, is the only victim who has shown improvement. He was upgraded to satisfactory condition yesterday in intensive care at Harborview Medical Centre in Seattle.

He posted a message of forgiveness on Twitter: "I love you and I forgive you jaylen rest in peace."

Gia's family said her organs would be donated.

"We are devastated by this senseless tragedy," her family said. "Gia is our beautiful daughter, and words cannot express how much we will miss her."

Mr Trenary also confirmed that the .40-calibre handgun used in the shooting had been legally purchased by one of Fryberg's relatives. It remains unclear how Fryberg obtained the weapon.

A medical examiner yesterday ruled Fryberg's death a suicide. There had been some question over whether he might have shot himself accidentally as a teacher tried to intervene, but Mr Trenary said that investigators confirmed there was no physical contact between the teacher and the gunman.

At the memorial outside the school yesterday, a group of mourners hugged each other tightly at 10.39am - the minute the shooting was reported on Friday.

Flowers and signs were tied to a chain-link fence lined with red and white balloons reflecting the school's colours. Many said that the victims would be missed.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.