WARSAW, Poland (AP) - Prince William traveled to Poland on Wednesday for a surprise visit that underscored Britain's support for a nation on the front line of efforts to help refugees displaced by Russia's war in Ukraine and to assist the Ukrainian military in fighting off the invasion.

The heir to the throne met with British and Polish troops in Rzeszow, a city of 200,000 people in southeastern Poland that has become a hub for shipments of military and humanitarian aid bound for Ukraine.

“I just wanted to come here in person to say thank you for all that you're doing, keeping everyone safe out here and keeping an eye on what's going on,” William said as he spoke to the troops.

“You're doing a really important job out here and defending our freedoms is really important, and everyone back home thoroughly supports you,” he said.

Located just 65 kilometers (40 miles) from the Ukrainian border, Rzeszow is also a key transit point for refugees.

William later landed in Warsaw, where he visited a center that houses about 300 recent arrivals from Ukraine, meeting Ukrainians and playing table tennis with children.

He praised the strong ties between the people of the U.K. and Poland, and the cooperation undertaken in support of Ukraine.

“I also want to pay tribute to the inspiring humanity of the Polish people,” the prince said. “You have opened your hearts as much as your homes.”

The U.K. has been one of the most outspoken supporters of bolstering NATO's eastern flank in the face of Russia's aggression. The country sent troops to Poland and the Baltic states and provided more than 2.3 billion pounds ($2.8 billion) of military aid to Ukraine. It also has pledged 220 million pounds ($269 million) of humanitarian assistance.

But deploying the popular 40-year-old prince, a military veteran who also worked as a civilian air-sea rescue pilot, offers a more personal touch. While British political leaders have visited Poland regularly to trumpet their support for NATO and the Ukrainian cause, a senior royal like William is a symbol of the nation who can thank military personnel for their service without the baggage of party politics.

The prince's planned meetings with refugees and volunteers also shine the royal spotlight on efforts to shelter the hundreds of thousands of Ukrainians who have settled in Poland over the past year.

On Thursday, he is also scheduled to meet with President Andrzej Duda and to talk with young Ukrainians who are working and studying in Poland.

“Our nations have strong ties,” William said Wednesday. ”Through our cooperation in support of the people of Ukraine and their freedom, which are also our freedoms and yours, these ties are further strengthened.”

Kirka contributed from London.