"What we're seeing now is the greatest challenge for Europe in the coming years, I have no doubt about that," Rajoy said during a visit to Berlin.
Meanwhile Hungarian police evacuate Budapest's international railway station where hundreds of migrants tried to board trains to Austria and Germany.
Also in Austria police in Vienna say 3,650 migrants arrived from Hungary Monday at the city's Westbahnhof station. They say most continued on toward Germany.
German Chancellor Angela Merkel on Monday urged fellow EU nations to share responsibility for the refugee crisis facing the continent, warning that failure to find a common response could "ruin" the very foundations of the European project.
Germany expects to receive 800,000 asylum seekers this year, far more than any other European nation.
The surge in arrivals has given rise to xenophobia and reignited a debate about immigration. There have also been frequent attacks on asylum shelters.
Many of the asylum seekers are fleeing wars in Syria, Iraq and Afghanistan. But many others are economic migrants from the Balkans and Africa.