Prince William is making a surprise two-day visit to Poland, starting with a military base along the border with Ukraine Wednesday to thank troops for their commitment to helping the country defend itself against Russia. 

"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,'' the Prince of Wales told British and Polish troops gathered in Rzeszow, a city in the southwest of the country that has become a hub for shipments of military and humanitarian aid bound for Ukraine.

The city is around 40 miles from the Ukrainian border and is also a transit hub for refugees. 

"You’re doing a really important job out here and defending our freedoms is really important, and everyone back home thoroughly supports you," he added.

PRINCE WILLIAM CONDEMNS RACISM AGAINST YOUTH SOCCER CLUB, DEMANDS 'THOSE RESPONSIBLE BE HELD TO ACCOUNT'

Prince William speaking to the mayor of Warsaw.

Prince William made a secret visit to Poland on Wednesday.  (Photo/Czarek Sokolowski)

The base, which also includes U.S. troops, is used to secure Polish airspace and help send aid to Ukraine, according to the BBC. 

After he left the base, William flew to Warsaw where he planned to tour a refugee center that houses around 300 women and children. The prince's visit was kept secret for security reasons until he left the base along Ukraine's border. 

"Our nations have strong ties," the prince said of Poland and Britain. "Through our co-operation in support of the people of Ukraine and their freedom, which are also our freedoms and yours, these ties are further strengthened."

Prince William meeting with the mayor of Warsaw at a refugee center

Prince William met with the mayor of Warsaw during his visit.  (AP Photo/Czarek Sokolowski)

He added, "I'm here because I want to personally thank the Polish and British troops working in close and crucial partnership. I also want to pay tribute to the inspiring humanity of the Polish people. You have opened your hearts as much as your homes."

On Thursday, he’s expected to meet with Polish President Andrzej Duda. 

Prince William taking selfies with kids

Prince William visited refugee children in Warsaw.  (Photo/Czarek Sokolowski)

Several U.K. politicians, including former Prime Minister Boris Johnson have been to the region to show support for Ukraine, but William is the first senior royal to visit Poland since Russia’s invasion last year. 

In May, King Charles traveled to Romania to meet with Ukrainian refugees.

Prince William speaks a boy in a wheelchair

Prince William's visit was kept secret for security reasons until he left the base along Ukraine's border and flew to Warsaw.  (Photo/Czarek Sokolowski)

The U.K. has been one of the most committed 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.8 billion of military aid to Ukraine. It also has pledged $269 million in humanitarian assistance.

CLICK HERE TO GET THE FOX NEWS APP

William, a veteran and former civilian sea-air rescue pilot, has been an outspoken supporter of Ukraine as well. 

The 40-year-old last visited Poland in 2017 with wife Kate Middleton. They also met with Ukrainian President Volodymyr Zelenskyy and his wife at Buckingham Palace in 2020. 

The Associated Press contributed to this report.