Police said CCTV footage showed the 16-year-old suspect take a gun out of his rucksack before shooting his victims at the Saugus High School in Santa Clarita, Los Angeles County.
He then shot himself in the head and is now in a “grave condition” in hospital, police added.
Officers recovered a weapon at the scene.
A 16-year-old female student and a 14-year-old male student have been confirmed as those who died.
Two female victims aged 14 and 15 and another male victim aged, 14, were also injured.
Officers said the suspect is an Asian male student at the school who turned 16 today.
He was said to be carrying a semi-automatic pistol and wearing black clothing and a black hat at the time of the attack.
Police have said they are still trying to determine the motive for the shooting.
Officers were seen surrounding a nearby property after the attack.
The suspect’s girlfriend and his mother are at a police station while he is being treated in hospital.
The Santa Clarita Valley branch of the Los Angeles County Sheriff’s Office said on Twitter: “We believe at this time that there is only one suspect but we are actively investigating and following all leads.”
Helicopter footage aired on US television shows lines of students with their hands in the air, filing out of school buildings and being led by police officers.
Teresa Figueira, a student at the school, said: “I was walking with my sister and we were walking into school and then I heard a shot.
“All of a sudden I saw kids running and I thought it was a joke.
“Then I saw my sister running saying ‘go go go’, so I ran and my friend told me to go to his house because he lives on the street.”
She added: “It was terrifying.”
An unnamed female student told NBC News: “I was really, really scared. I was shaking.”
She added that she saw one person lying on the ground covered in blood.
The student said she was doing homework when people started running, and she hid under a table until police entered the building.
The mother of student Anthony Peters told NBC he was still on lockdown inside the school but had texted that he was uninjured.
Mr Peters’ mother said he told her: “One of the teachers said ‘there is an active shooter. I heard the shots and saw three kids get shot’.”
Several pupils were placed on stretchers and taken to ambulances in the school’s car park, according to the LA Times.
Some of the wounded were being treated in a grassy area on the school’s campus, the paper added.
Some 2,300 students attend the school, which is made up of more than a dozen buildings.
Other schools in the area were placed on lockdown.
The attack was yet another school tragedy in the US, where repeated mass shootings in recent years have intensified the debate about gun control.