(Bloomberg) -- European Union ministers struck a hard-fought deal Thursday on how to approach migration and asylum policies after years of thorny negotiations.

The nations agreed on an asylum approach that would allow countries to make decisions about granting access to applicants and to ensure procedures to return migrants who don’t qualify, Sweden’s migration minister, Maria Stenergard, told reporters. The ministers also agreed on providing EU support to the countries most exposed to migration, she added.

The result, she said, “is grounded in European values and international law.” Countries that don’t agree to accept qualified migrants would have to contribute €20,000 ($21,559) per person to an EU refugee fund under the tentative agreement. Only two EU members voted against the deal, while four abstained.

“It’s clear we have made huge progress when it comes to building trust,” EU home affairs commissioner Ylva Johansson said at a news conference.

The EU has long struggled to reach a common approach on migration, particularly as successive crises have strained frontline countries. The entry of migrants — mainly from Syria, Afghanistan and Tunisia — has been growing, even as 13 million Ukrainians sought shelter in member states after Russia’s invasion. Around 10 million Ukrainians also left the bloc during that time. 

The flow of migrants through the western Balkans accounted for almost half of all illegal border crossings into the EU in 2022. 

Read more: Europe Tackles Migration Policy in the Shadow of Russia’s War

There are still a number of hurdles before anything is implemented. Thursday’s deal clears the way for negotiations between member states and the European Parliament. 

Earlier Thursday, German Chancellor Olaf Scholz said he was ready to work with Italian Prime Minister Giorgia Meloni to tackle the asylum question.

“All attempts to either leave the problems with someone else or to point the finger at others will fail,” he said at a joint news conference in Rome. “It is important to establish reliable cooperation with countries of origin and countries of transit.”

Meloni, whose party has post-fascist roots, echoed her guest who is a center-left Social Democrat. “There is now a consensus that a shift is needed on migration rules, and for this I want to thank Mr Scholz,” Meloni said.

Based on jointly agreed EU rules, authorities are supposed to register asylum seekers in the country of arrival. But in practice, authorities often let migrants pass on to countries such as Germany, a practice which has caused some tensions among European countries. Germany exempts Ukrainian war refugees from having to apply for asylum status. 

Read more: Germany and Italy Pledge Closer Ties on Energy Supply, Migration

--With assistance from Chiara Albanese, Michael Nienaber and Niclas Rolander.

©2023 Bloomberg L.P.