Spanish police have arrested a 21-year-old man in Palma de Mallorca on suspicion of plotting to bomb the University of the Balearic Islands.
The suspect was seized as he received 140kg (310lb) of ingredients for explosives, apparently to be used for a Columbine-style massacre, police said.
He reportedly kept a diary where he wrote about hating society and that he was ready to die in his attack.
The suspect is believed to have been planning to plant pipe bombs on campus.
He was identified only by his initials, JMMS.
Montserrat Casas, the rector of UIB, as the university is known, said she was relieved that a tragedy had been avoided thanks to police action.
There was no evidence, she said, that the detainee had ever studied at UIB or had had any other connection to it, nor had the university ever received any threatening letters.
‘Columbine posts’
Police began investigating five months ago after finding comments online about the Columbine High School massacre in the US, when two former pupils murdered 12 students and a teacher.
The suspect expressed sympathy for the killers, teenagers Eric Harris and Dylan Klebold, Spanish police said.
“In his blog he included sections in which he spoke about having identical tastes in music, a liking of weapons, clothing and even the social isolation which led him to be marginalised in school,” a police statement said.
“In his personal diary and other documents seized at his home, the detainee showed his hatred of society, especially university students, and his decision to strategically place shrapnel-filled pipe bombs in the university grounds, admitting to a possible suicide in the carrying out of the massacre.”
He is said to have initially tried to purchase guns to carry out the attack but then opted for bombs and was arrested at 10:30 local time (08:30 GMT) on Wednesday as he received the explosives.
Police released a photo of the explosive ingredients, including ammonium and potassium nitrate, both used in fertilisers; sulphuric and nitric acid; and sodium sulphide.
UIB, which is located in Palma, has 16,400 students.