VATICAN CITY (AP) — Hungarian Prime Minister Viktor Orban met with Pope Francis at the Vatican on Thursday as the war in Ukraine and the millions of refugees it has created cast a shadow over two leaders who have long sought closer ties with Russia.

The 45-minute meeting was the second between Francis and Orban in less than a year, but couldn’t have been more different in tone. The pope made a brief stop in Budapest to close out a church congress, and the awkwardness of that September encounterwas evident given his and nationalist Orban’s starkly different views of mass migration to Europe.

But on Thursday, a smiling and jovial Francis showed his appreciation for the welcome Hungary had provided to Ukrainians fleeing the Russian invasion. He gave Orban a medallion of St. Martin and said he chose it specifically to honor Hungary’s reception of refugees.

Hungary has emerged as a major transit country for the war’s refugees. More than 476,000 people have entered the country’s territory from Ukraine since the conflict began eight weeks ago, according to the U.N. refugee agency.

Francis and Obran laughed frequently during Thursday’s encounter. When it was time for them to part, the pope told the prime minister in English: “May God bless you, your family and Hungary.” Orban replied “Your Holiness, we are waiting for you,” an apparent reference to Francis’ plans to return to Hungary for a pastoral visit sometime in the future.

While Orban’s government adopted anti-immigration policies in the past, it said it would welcome all those fleeing Ukraine and provide them with food, accommodation and the opportunity to work. That contrasts with Europe’s last wave of refugees.

When over 1 million people, mostly from Iraq and Syria, arrived in the European Union in 2015, Orban ordered the construction of a razor-wire fence along Hungary’s southern border and put up legal roadblocks to asylum-seekers.

Orban’s visit to the Vatican was his first foreign trip since he and his right-wing Fidesz party won Hungary’s April 3 national election, and the destination represented a departure from what has become his tradition following past elections.

Soon to begin his fourth consecutive term, Orban – the longest-serving leader in the EU – traveled to Poland’s capital, Warsaw, to visit allies after the 2010, 2014 and 2018 Hungarian elections.

Poland is Hungary’s strongest EU ally, and the government’s of the two countries have supported each other in their respective battles with the bloc over allegations that their populist governments have eroded judicial independence, media freedom and the rule of law.

But the war in Ukraine has put the warm relations between Budapest and Warsaw to the test, revealing fault lines caused by differing approaches to Moscow.

Poland, which has traditionally seen Russia as a major security threat, has been among Europe’s most active players in pushing for sanctions against Moscow and providing military aid to Ukraine.

Orban has long pursued close ties with Russian President Vladimir Putin, and in recent weeks refused to supply Ukraine with weapons or allow their transfer across the Hungary-Ukraine border. The Hungarian government also has lobbied heavily against expanding EU sanctions to include a ban on Russian energy imports, on which Hungary is dependent.

Francis, for his part, has long sought to improve relations with the Russian Orthodox Church. In 2016, he became the first pope in a millennium to meet with the church’s leader, Russian Patriarch Kirill.

Francis initially offered restrained criticism of the Russian invasion of Ukraine, maintaining the Vatican’s diplomatic tradition. But he has increasingly expressed outrage over what he called a “sacrilegious” war and the creation of millions of Ukrainian refugees, while still refraining from calling out Russia or Putin by name.

Francis is still seeking to keep open a path of dialogue with Kirill, however. They spoke by video call last month, and there have been reports they might meet face-to-face in Jerusalem in June.

___

Spike reported from Budapest, Hungary.

___

Follow AP’s coverage of the war in Ukraine: https://apnews.com/hub/russia-ukraine