They said he is obsessed with guns and had relationship problems, and the incident was not apparently terror-related. The name of the suspect, a minor, has not been disclosed.
Education Minister Najat Vallaud-Belkacem said "heroic" actions by the school's head teacher appeared to have helped prevent greater bloodshed.
The head teacher rushed towards the pupil as he pulled out his guns "to try to reason with him," Vallaud-Belkacem said, adding that the educator was injured in the process.
"We avoided the worst," she said.
Three pupils and the head teacher suffered minor gunshot injuries, and another six students were treated for shock or injuries sustained during a stampede, according to an updated toll.
The assailant's age was initially given by investigators as 17, but they later amended it to 16.
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 - which may have been dummy devices - when he was detained by police shortly after the lunchtime attack.
Investigators also found a homemade explosive device in his rucksack, which was made safe on the spot.
He used a pump-action firearm, but not the other weapons, and offered no resistance to his arrest, the prosecutor said.
The suspect had shared pictures and videos on social media of infamous US school shootings, including the 1999 Columbine massacre in Littleton, Colorado, in which two teens killed 13 people before committing suicide.
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.
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.
Sonia, 42, the mother of a 16-year-old girl called Ines, said she had received a text message from her daughter at 12:30 pm (1130 GMT) that said, "We are going to die, someone has a gun, I love you, Mum. Goodbye!"
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 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.
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.
Election Results for Lok Sabha Election 2019 will be out on May 23. Get the latest election news and live updates on ndtv.com/elections. Catch all the action on NDTV Live. Like us on Facebook or follow us on Twitter and Instagram for news updates from each of the 543 parliamentary seats for the election 2019