Police have captured an armed man who had taken 25 children hostage at a school near Barcelona.
None of the students was hurt.
The man had released 21 of the 25 captives in two groups, and about 45 minutes later the government said he had been detained.
It is not known if police stormed the school or the assailant surrendered.
Sixteen were released about two hours after the hostage-taking began in Hospitalet de Llobregat. Shortly afterwards, another five students were freed.
Spanish Interior Minister Angel Acebes, speaking in the central city of Guadalajara, confirmed the arrest and said the hostage-taker was a former pupil of the school.
As a car left the schoolyard, apparently taking the assailant to a police station, a crowd swarmed around it and many people screamed insults.