An armed man took 21 students hostage at a school in Sable-sur-Sarthe in western France.
Police evacuated the school premises as the man barricaded himself and his hostages in an upstairs classroom.
Special agents negotiated with the man, who used to work at the school and was reportedly angry at being unemployed.
Relatives of the hostages rushed to the school as news of the incident spread.
The man had allowed students to call or text their parents on their mobile phones.
Police set up a crisis centre for parents and students, but the incident was resolved peacefully with the man's surrender.