A 13-year-old boy armed with a crossbow and knife has killed a teacher and wounded four others at his school in Barcelona before being subdued, police and witnesses said.
It is the first documented case of a murder of a teacher at a school in Spain since the country returned to democracy after the death of longtime dictator Francisco Franco in 1975, according to Spain's ANPE teachers' union.
The attack, which took place just after classes began, sowed panic at the Joan Fuster secondary school, which has about 500 students and 40 teachers.
"There were screams from another classroom, the teacher went out into the hall. We heard a really loud noise, we looked into the hall and saw the teacher lying on the ground," said Maria Camila Ospina, a 13-year-old pupil.
"We hid behind desks and chairs and the boy entered the classroom, he looked for a classmate and stabbed him in the thorax and went out into the hall again," she told AFP.
The boy had a crossbow and a knife, she said, adding that students piled desks and chairs against the classroom door, and ran out to the courtyard when the attacker was far away.
Police did not say which weapon killed the teacher, but sources close to the investigation confirmed the boy was found with a knife and a crossbow.
The motive is unclear for the attack, which comes on the 16th anniversary of the 1999 Columbine High School massacre in the United States, when two teenagers shot dead a teacher and 12 classmates before committing suicide.
The boy, who was eventually subdued by a gym teacher, may have suffered a "psychotic episode", the regional education minister, Irene Rigau, told a news conference.
Several students said the slain teacher was a substitute teaching social sciences at the school, which is in a middle class neighbourhood of Spain's second-largest city.
Police said the lives of four other people injured in the attack -- two teachers and two students -- were not in danger.
One of the wounded teachers was treated at the scene and released, while the other three casualties were taken to hospital.
Among the injured were a Spanish language teacher and her daughter, also a student at the school, according to Spanish media reports.
'Liked everything military'
Spanish media reported the boy had spoken of killing all his teachers last week, and had a list of names, but his classmates had dismissed his comments as a joke.
"If you knew the boy, you wouldn't be able to imagine that he could do something like this. The only strange thing about him is that he likes everything related to the military, the army, weapons. He would even come to school wearing military fatigue pants," Ospina said.
The regional government of Catalonia, whose capital is Barcelona, declared a day of mourning.
Prime Minister Mariano Rajoy said he was "shocked" by the attack while Education Minister Jose Ignacio Wert sent a message to the teacher's family and the school director expressing his "deep regret".
Police and medics rushed to the scene and the boy was taken to hospital to be examined by a psychiatric unit.
Under Spanish law children below the age of 14 are not held legally responsible for crimes and cannot be jailed, although they can be sent to psychiatric hospitals.
Prosecutors said the boy would likely be turned over to regional child protection services.