A 16-year-old student opened fire at a high school in southern France, wounding two other students and the principal trying to intervene, officials have said.
Police moved into the Alexis de Tocqueville school in the town of Grasse - the country's picturesque perfume capital - and arrested the still-armed suspect, identified by an interior ministry spokesman as Killian Barbey.
The motive behind the shootings was not immediately clear.
School shootings are rare in France, and a national police official said authorities have no reason to suspect it was terrorism-related.
He added that there did not appear to be any other suspects, although police worked to "remove all doubt".
The principal and two others were hit by bullets, while five more were treated for shock, the police official said. None of the injuries was life-threatening.
The student was arrested in possession of multiple weapons after the attack, a police official said.
Education minister Najat Vallaud-Belkacem, who visited the school, called it "the crazy act of a fragile young man fascinated by firearms ... We just missed the worst".
Interior ministry spokesman Pierre-Henry Brandet said the suspect was 16 years old, not 17 as police initially reported.
During the attack, some students hid at the school and others were evacuated.
A police helicopter circled overhead in what is normally a relatively quiet corner of France.
Police cordoned off the area and worried residents gathered outside in the town, which is 40 kilometres (25 miles) from the southern city of Nice, site of last year's Bastille Day terror attack that killed 86 people.
The president of the region, Christian Estrosi, said the principal suffered an arm wound and told him that after being alerted to the presence of the armed student, "he tried to interpose ... to try to calm him, and unfortunately he didn't succeed".
A visibly shaken student told BFM TV that he heard four shots, then "it was total panic" at his school.
"I was downstairs ... We started to run. I was with a buddy and we took refuge upstairs," said the young man, identified only as Andreas.
"Then the riot police arrived ... It was like in a film."
"We hear this kind of thing in Paris. Now we understand what it is," he said.
By mid-afternoon, Mr Brandet said all students at the school were safe.
He said it is too early to know the motives for the attack, which came as France remained under a state of emergency after a string of deadly Islamic extremist attacks over the past two years.
President Francois Hollande said that, while no terrorism link has been identified, "all this justifies the state of emergency", adding that it would remain in place until July 15, as planned.
A worker at a nearby electronics shop said police had asked residents to stay indoors.
An employee of sports chain Decathlon, which has a branch less than 500 metres from the high school, said he had seen about 40 high school students leaving and gathering in a nearby car park.
The government sent out an alert warning of an attack after police reported that shots were fired, but later lifted it.
The alert is part of a system implemented by the government after the deadly November 2015 attacks in Paris.