A Spanish teenager armed with a crossbow killed a substitute teacher and injured four others at a Barcelona school on Monday in what police believe is the country's first school attack in recent history.

Students were settling into the school day when the unidentified 13-year-old, also armed with a machete, killed the teacher and wounded two students and two more teachers, the Associated Press reported.

"We were just starting the class and suddenly we heard screams," student Gemma Jarque told the AP of the 9:30 a.m. attack. "So we shut ourselves inside our classroom in order to be safe."

Local police did not disclose how the attack occurred. Jarque said they hid inside the classroom and escaped when a fire alarm went off.

"We saw the teacher lying on the floor in a pool of blood," she said.

Three of the wounded were treated at a Barcelona hospital. The fourth was treated at the school for kids ages 12 to 16, the AP reported.

An unnamed national police spokesman said he could not recall the last fatal attack to occur at a Spanish school in recent history.

Officials said the alleged attacker, whose name is withheld due to his age, is in custody and is to undergo psychiatric evaluation.

"He was very disturbed and saying strange and incoherent things," Miguel Company, a spokesman for Barcelona's prosecutor's office, told the news agency.

The boy is not to face criminal charges or be jailed because those under 14 years of age are not legally responsible for their actions under Spanish law.

But minors can be sent to mental health facilities if it's warranted, a Justice Ministry spokesman told the AP.

The boy is currently at a hospital for his mental evaluation so officials can determine if he is faking a psychiatric condition, Company said.