Education Minister Najat Vallaud-Belkacem praised the "heroic" head teacher of Alexis de Tocqueville high school in the sleepy hillside town of Grasse who appeared to have helped prevent greater bloodshed.
He rushed towards the student as he pulled out his guns "to try to reason with him," Vallaud-Belkacem said, adding that he was injured in the process. "We avoided the worst," she said.
Three pupils and the head teacher suffered minor gunshot wounds, while another 10 students were hospitalised for shock or injuries sustained during a stampede, Vallaud-Belkacem told reporters at the scene.
Local prosecutor Fabienne Atzori ruled out a terror motive and said the shooting appeared to have been motivated by the gunman's "bad relationships" with classmates.
'Fascinated by guns'
The teenager was described by Vallaud-Belkacem as "unstable and fascinated by guns" and was carrying a rifle, two handguns and grenades when he was detained by police shortly after the lunchtime attack.
He offered no resistance to his arrest, the prosecutor said.
The suspect, who has not been named publicly as a minor, had shared pictures and videos on social media of infamous US school shootings, including the 1999 Columbine massacre.
Children leave their high school after an attack in a high school in Grasse, southern France, Thursday, March 16, 2017 (AAP) Source: AAP
France is still in a state of emergency after a series of terror attacks, including the November 2015 massacre in Paris and a truck attack in Nice, just 40 kilometres (25 miles) from Grasse, in July last year.
Many feared the worst when news first filtered through of the violence, with elite police response teams immediately dispatched to the scene.
The shooting comes around 40 days ahead of the first round of France's two-stage presidential election, in which security is one of the main issues on voters' minds.
'We ran for it'
Witnesses described scenes of panic as pupils fled the shooting or looked for places to hide.
Fifteen-year-old Mokhtaria told AFP she was having a cigarette in the school garage when she heard shots ring out.
"We saw people coming down shouting: 'There's a nutter firing at people'. We ran for it," she said.
All schools in Grasse were locked down after the shooting and police threw a cordon around the building in the town which is home to several perfume factories.
Security is at its highest possible level in France following the spate of jihadist attacks since January 2015 that have claimed hundreds of lives.
More than 3,000 reservists were called up to help keep watch outside the country's 64,000 primary and secondary schools when pupils returned from their summer holidays in September.
Prime Minister Bernard Cazeneuve cut short a trip in northern France because of the Grasse shooting, as well as a letter bomb blast at the offices of the International Monetary Fund in Paris on Thursday.
A secretary at the agency suffered burns to her hands and face after opening a parcel containing explosive material believed to be a firework.
Greek police pointed the finger at anarchists who were behind another parcel bomb sent to the German finance ministry this week.
IMF chief Christine Lagarde condemned the letter bomb as a "cowardly act of violence".
Many Greeks blame Germany and the IMF for imposing years of public sector cuts and reforms in exchange for bailout packages needed to prop up the recession-hit country.
US-style school shootings are almost unheard-of in France, a country with low levels of gun violence.
The last major attack at a school was in 2012, when an Islamic extremist from Toulouse, Mohamed Merah, shot dead three children and a teacher at a Jewish school in the city before being killed by police.
In March 1984, a 15-year-old student shot and killed a teacher in the southwestern town of Castres before turning the gun on himself.