A number of the demonstrators clashed with police after marching to the central Sol square chanting slogans.
Earlier, Spanish police arrested a Mexican student for allegedly plotting to gas the anti-Pope rallies.
The trip comes at a time of economic hardship in Spain, although organisers say the pilgrimage is self-funded.
Up to a million pilgrims from across the world have gathered in the city for the six-day World Youth Day (WYD 2011) festival, which culminates with an open-air mass on Sunday celebrated by Pope Benedict XVI.
The Pope will arrive at Madrid's Barajas airport on Thursday morning and hold meetings with young people at WYD 2011 later in the day.