The 14-year-old student arrived at the school in the southern province of Kahramanmaras armed with five guns and seven magazines in his backpack, provincial governor Mukerrem Unluer said.
The guns are said to belong to the teenager's father.
The attacker, who was in the eighth grade at the school, was killed, although it is unclear whether he was killed by police or his death was self-inflicted.
The motive for the shootings, which took place across two classrooms, wasn't immediately known.
The shootings come just a day after 16 people, including students and teachers, were injured when a former student opened fire at a high school in the nearby Sanliurfa province.
The gunman later turned the gun on himself.