Spanish police arrested Tuesday in Madrid a 24-year-old Mexican man who was apparently planning to attack people protesting the impending visit of Pope Benedict XVI to take part in the celebration of World Youth Day.

The suspect, identified by the initials J.A.P.B, was arrested without offering any resistance outside one of the pavilions at the Ifema fairgrounds, where many of the pilgrims are staying who came to Madrid for the youth event, police said.

The suspect is a student at Spain's General Organic Chemistry Institute and planned an attack using asphyxiating gases and other chemical substances.

Seized at his home in Madrid was a USB flash drive memory for computers and two notebooks with notes about chemical processes that had nothing to do with his chemistry studies.

Judicial authorities told Efe that the man in custody had allegedly announced on Internet forums his intention to mount an attack on people opposing the pope's visit.

A Spanish court issued a warrant to search his workplace and his home.

The visit of Benedict XVI, due to arrive in Madrid on Thursday, has sparked widespread protest from groups, some of them Catholic, that oppose the use of public funds amid Spain's economic crisis.

Though the organizers and the government of Prime Minister Jose Luis Rodriguez Zapatero say that the benefits of the visit will cover the costs, an association of anti-clerical organizations has called for a demonstration on Wednesday in downtown Madrid.

Under the slogan "None of my taxes for the pope," the demonstrators will march down the capital's main thoroughfares following tough negotiations with local authorities to establish the protest route.