Pope Benedict XVI arrived Thursday for his third visit to an increasingly secular Spain, which the Vatican wants to rediscover its Christian roots, DPA reported.
King Juan Carlos and Queen Sofia were waiting for the 84-year-old German pontiff at Madrid's Barajas airport.
Other dignitaries included Prime Minister Jose Luis Rodriguez Zapatero, whose Socialist government has frequently been at odds with the Vatican over social reforms such as homosexual marriage, easier access to abortion and speedier divorce.
However, the government's relations with the Vatican have improved in recent years.
Benedict was visiting Madrid on the occasion of the six-day World Youth Day celebrations, which culminate in a gigantic open-air mass celebrated by him on Sunday.
About 2,000 young people were at the airport, representing almost one million pilgrims from around 190 countries who have converged on Madrid, according to government figures.
The city has been full of pilgrims in recent days, dressed in colourful T-shirts, carrying national flags, singing, buying papal souvenirs and seeking refreshment from the sweltering heat at the city's fountains.
On Thursday, however, cloudy weather offered some relief from the heat.
The pope's visit has also sparked criticism, mainly over its cost, which is estimated at a minimum of 50 million euros (70 million dollars).
While most of this is covered by pilgrims' fees and by sponsors, the city has also deployed 10,000 police officers, reduced transport fares for pilgrims and offered public buildings such as schools to lodge them.
Eleven people were injured on Wednesday, including two police officers, as the police tried to prevent demonstrators from clashing with Catholics wearing crucifixes and chanting "long live the pope."
Eight people had been detained, police said Thursday.
"They will not spoil the party for us," said Spanish Bishops' Conference spokesman Juan Antonio Martinez Camino.
The pope's visit to Madrid is his 21st trip abroad since he was elected pontiff in 2005, and his third to Spain. Benedict earlier visited Valencia in 2006 and Santiago de Compostela and Barcelona in November.