MADRID—A Spanish man arrested on suspicion of planning to imitate the 1999 Columbine killings at a university campus on the popular holiday island of Mallorca was ordered Friday to remain in custody while a judge decides what legal action to take.

The suspect, identified by officials only as a 21-year-old whose initials are J.M.M.S., was shown on state television TVE as he was escorted to court by police.

Judge Enrique Morell handed down a decision of provisional prison without bail for the suspect, who was arrested Wednesday. The judge said he had decided to keep the man in custody to avoid any risk he might tamper with evidence.

A court spokeswoman said the suspect entered the courthouse smiling before answering questions posed by Morell. The official spoke on condition of anonymity because she wasn't authorized to speak to the media.

Spanish police said the man had tried to purchase guns for the attack, but opted to make bombs from 140 kilograms (310 pounds) of chemicals bought online.

In a statement, police said they had been watching the man for the past five months after messages referring to Columbine began appearing on Internet pages in Spain. A Venezuelan journalist working in Japan alerted police to the suspicious content of some of the suspect's online postings.

The statement said the man had openly expressed his hatred for society, and particularly students. A police spokesman said there was nothing to indicate that the man had planned to carry out the attack for any set ideological reasons.

Twelve students and one teacher were killed in the Columbine attack in Colorado. The two perpetrators then killed themselves. The Spanish man's diary indicated he had considered committing suicide once he had carried out the attack.