Humboldt University of Berlin is illuminated during the 10th annual Festival of Lights in Berlin in 2014. (Paul Zinken/European Pressphoto Agency)

BERLIN — Germany is home to some of the world's best public universities, so it might stun Americans that attending them is essentially free: These academic giants don't charge any tuition fees at all. Many even offer degrees taught fully in English, programs specifically created to attract foreigners willing to come to Germany.

But non-Germans looking to cash in on the bargain might have to do so quickly: Some states in Germany are reversing the tuition-free policy for many foreigners.

Baden-Württemberg, one of Germany's 16 states, has already introduced tuition fees for students who don't hold European Union citizenship. Germany's most populous state, North Rhine-Westphalia, or NRW, is expected to follow suit. A spokesperson for the state's science ministry confirmed the plans on Monday, saying that the additional financial resources would be used to improve the quality of higher education overall.

The estimated tuition fee of $3,500 will still be significantly less than what schools in the United States and Britain charge. But the change indicates a significant shift for Germany, which had been focusing on recruiting talent from abroad.

Germany's population is rapidly aging and lacks hundreds of thousands of skilled young workers. German companies are increasingly forced to reject lucrative contracts due to their inability to hire workers, and more may be forced to slow production in the future as the number of working-age Germans declines even further. According to some estimates, the shortage of skilled workers may rise to 3.3 million by 2040, when Germany is projected to have about 80 million inhabitants.

The influx of over 1 million refugees over the last four years may have relieved the country's labor shortage in some industries, but employing the majority of the newcomers will take decades.

Meanwhile, more than 40 percent of all international students in Germany focus on mathematics, natural sciences or engineering — academic fields in high demand among employers. In contrast to Britain, where Prime Minister Theresa May is intent on lowering the number of foreign students, Germany has sought to keep as many of those graduates in the country as possible.

Offering international students tuition-free degrees was considered one possible solution — albeit a costly one. Interest from abroad has been on the rise for years, and the number of international students increased by 50 percent between 2002 and 2012. Most non-E. U. students currently come from Turkey, China, Russia and India. Americans also make up a sizable number of that group: In 2013, there were more postgraduate students from the United States enrolled in German universities than from neighboring France.

But there are concerns that German higher education doesn't adequately prepare foreign students for the country's labor market. Although they have 18 months to search for jobs after finishing their degrees — more than in most other nations — many still struggle to find employment, according to a 2015 study. Four in five foreign students in Germany were determined to stay in the country after graduation, but 30 percent of them had to search for jobs for more than a year despite the acute labor shortage. German applicants found employment significantly faster than their foreign-born peers.

There are other complications, as well. Salaries in cities like Berlin that are popular with foreign graduates are comparably small, and teaching degree programs entirely in English offer few incentives for students to learn German, which many companies still require employees to be able to speak at some level.

Such imbalances have raised questions about whether the money spent on government-subsidized English-language degrees could be invested more successfully in schools or infrastructure projects. Some parts of Germany want to focus on offering cheap education at higher quality, both to German and international students.

“The success of many students depends mostly on the direct exchange with professors. However, many of them simply do not have time to sufficiently support their students,” argued the government of North Rhine-Westphalia's government in a recent policy proposal.

The state also does not expect a decrease in international student numbers due to the introduction of tuition fees. “The experience from abroad shows that students — especially those coming from Asia — consider themselves customers and are willing and able to pay, especially if the offer is of high quality,” said a representative for the NRW science ministry.