(Bloomberg) -- German Chancellor Angela Merkel urged European Union nations to confront racist attitudes, and called for a joint approach to tackle the challenges posed by the inflows of migrants.

“The racist tendencies that we see lamentably in all the member states is something we have to fight against,” Merkel said in a meeting in southern Spain with Spanish Prime Minister Pedro Sanchez, according to translated comments aired by Spain’s state broadcaster.

The talks in Sanlucar de Barrameda, near Cadiz, mark Merkel’s return to the European stage after a three-week vacation. As migration flows to Europe shift to Spain, Sanchez has emerged as an ally to the chancellor in dealing with the influx and promoting French-German proposals for the euro region, which include establishing a shared budget.

When Sanchez met Merkel in Berlin in June within a month of taking office, he said his government would “enthusiastically support” the French-German blueprint.

The two leaders met in Cadiz province, near the region where growing numbers of migrants have been arriving by sea from northern Africa. Spain this year overtook Italy and Greece as Europe’s favored destination for asylum seekers, accounting for almost half of more than 63,000 arrivals from land and sea, according to data from the United Nations refugee agency.

Sealed Accord

That makes Spain a critical ally for Merkel in countering illegal migration to Europe, which sparked a German coalition clash in June that brought the chancellor to the brink of losing her parliamentary majority.

The two governments sealed a migration accord ahead of Merkel’s visit, building on pledges by Spain, Greece and Italy at an EU summit in June to let Germany send back newly arriving asylum seekers who register in one of the three countries but then make their way to the German border. The accord, which takes effect Saturday and was welcomed by Merkel, allows Germany to send those asylum seekers back to Spain within 48 hours.

Merkel said European countries had to work together to create a fair system. It should be possible to distribute those who have a right to stay fairly among countries, she said.

“It is a common challenge for everyone -- it can’t depend on the geographic location of a certain country,” she said. Part of the solution lies in working with the countries of origin of the people arriving in the EU, she said.

Morocco Support

Merkel and Sanchez both said it’s also important to give more support to Morocco, where many of the migrants take to sea. That could take the form of financial aid, the leaders said, according to a separate statement from the Spanish government.

Merkel and Sanchez highlighted the need to work together on handling both migrant arrivals to the coasts of Europe and also their secondary movements, and all member states must assume their responsibilities, the statement said.Merkel’s coalition crisis began when her interior minister, Horst Seehofer, threatened to turn away asylum seekers at the German border if they previously registered in another EU country. Merkel, citing the risk of a cascading resumption of border controls in Europe, rejected unilateral measures.

Sanchez also has a reservoir of goodwill stemming from Spain’s economic recovery, which Merkel has regularly praised since the country emerged from a euro-area bailout for Spanish banks in 2012.

A Socialist who heads a minority government, Sanchez in June raised Spain’s 2018 budget-deficit forecast to 2.7 percent of gross domestic product from a previous estimate of 2.2 percent. Merkel, who generally avoids criticizing fellow euro-area governments’ fiscal performance in public, hasn’t commented on the looser target.

To contact the reporters on this story: Patrick Donahue in Berlin at pdonahue1@bloomberg.net;Arne Delfs in Berlin at adelfs@bloomberg.net;Charles Penty in Madrid at cpenty@bloomberg.net

To contact the editors responsible for this story: Alan Crawford at acrawford6@bloomberg.net, Keith Campbell, Andre Janse van Vuuren

©2018 Bloomberg L.P.