MILAN (Reuters) - Italy and Hungary, two fierce critics of European immigration policy, vowed on Tuesday to work together to pursue a new hardline approach to migrants searching for a new life inside the European Union.

Slideshow ( 5 images )

Italian Deputy Prime Matteo Salvini, who has ordered ports closed to most migrant arrivals by sea, and Hungarian Prime Minister Viktor Orban, whose government built a border wall, cemented their political ties in talks in Milan.

“We agreed that the most important issue is migration,” Orban said, adding that they had agreed to jointly pursue their anti-immigration agenda as the European Union enters campaign mode for EU parliamentary elections in May next year.

He said Hungary had shown immigration could be halted across land borders and that Salvini’s new Italian government had shown that it could also be stopped in the Mediterranean Sea.

“Europe’s security hinges on his success,” Orban said.

Italy and Hungary are both members of the European Union, which has drawn big numbers of asylum-seekers and poor migrants since 2015, most fleeing the Middle East and Africa.

Hungary was in the path of those fleeing the Syrian war, while those leaving Africa continue to head for Italy. Rome says it will not reopen its ports until its big EU neighbors agree to share the burden of taking in migrants rescued at sea.

Salvini and Orban said they agreed to work together ahead of European elections, though they belong to different factions. Salvini’s right-wing League is allied to France’s National Front while Orban is part of the center-right European People’s Party.

Both criticized French President Emmanuel Macron. Salvini accused him of not doing enough to help Italy on migration and Orban said the French president wanted to “blow up” the EPP.

“Macron is the leader of pro-migration parties in Europe today,” said Orban, whose visit prompted a protest in Milan by several thousand opponents of hardline immigration policies.

“And here we are, the ones who want to stop illegal migration. There is a big debate about this in the EPP as well. We would like our stance to be the general stance in the EPP.”

Salvini urged Macron to stop turning back migrants who try to enter France at the Ventimiglia border crossing with Italy.

However, Salvini said Italy was close to an agreement with Germany on migrant border controls.