
A third person was grazed in the shooting in the southern town of Aubagne near Marseille and the lives of the principal and teacher were not in danger, police said.
The suspected perpetrator fired several shots inside the school, before staff subdued the teenager and law enforcement intervened, France 3 television reported.
Education Minister Edouard Geffray said on X that a pupil at Joseph-Lakanal school was suspected of carrying out the shooting.
"This unacceptable act is yet further evidence of the rise of unchecked violence in our society, against which we must all take a stand," Geffray said on X.
The Marseille prosecutor's office confirmed an arrest, but did not give further details.
The prime minister's office said the interior and education ministers were heading to the scene.
Authorities said there did not appear to be a link with high school protests that have rocked France in recent weeks.
"The middle school was not affected by the high school students' protest," police told AFP.