The shooting took place at the Saugus High School in Santa Clarita, north of Los Angeles, minutes before the school day was due to begin.
Many US schools have implemented active shooter drills in recent years after fatal attacks around the country.
The shooting was first reported at 07:38 local time (15:38 GMT), LA county sheriff Alex Villanueva told a press conference. “Within seconds we received multiple [emergency] calls,” he said, adding that the first police units had arrived at the scene within two minutes.
Police found six people suffering from gunshot wounds and transferred them to local hospitals – and the suspect was later identified as one of those injured, Mr Villanueva said.
Two victims – a 16-year-old girl and a 14-year-old boy – died of their injuries, police said. The other victims were two girls aged 15 and 14, and a 14-year-old boy.
The suspect was “identified as a 16-year-old male whose birthday was today”, firearms expert Captain Kent Wegener said. He was named by US media as Nathaniel Berhow.
According to surveillance footage, the suspect took a gun out of his backpack and shot the five students, before turning the gun on himself. The weapon recovered was an emptied .45 calibre semi-automatic pistol, Mr Wegener added. Police said they had located the suspect’s home and would search it for evidence.