French police have detained a 17-year-old youth armed with two swords who took a group of children hostage.
The young man had initially taken around 20 children hostage in the eastern city of Besancon just after the school opened on Monday morning, but released a dozen shortly after, officials said.
Media reports said the remaining children were led out safely after being held for around four hours, along with their teacher.
The man "went into the establishment armed with two swords and declaring that he wanted something," but did not say what exactly that was, Jean-Louis Fousseret, the city's mayor said.
Officers had been in contact with the youth via the telephone.
French media have said the hostage-taker was known to suffer from depression, but no motive has been made clear.