Germany's upper house of parliament has approved an immigration law that aims to bring in skilled workers while protecting the country from terrorism.
Germany wants more professionals, particularly in science and IT
The law, which will come into effect early next year, follows years of heated debate on the issue.
More than 7m foreign nationals are already in Germany but most of them came as guest workers, not immigrants.
Supporters say the law is crucial as the country battles with an ageing population and a skills shortage.
This is Germany's first immigration law. It balances Germany's need for skilled migrant workers from outside the European Union, while also making it easier for the authorities to deport people who are suspected of supporting political violence.
It was approved by an overwhelming majority of the Bundestag (Germany's lower house) last week.
Its approval effectively puts an end to four years of bitter struggle, in which the conservative opposition fought the original government proposals in both the parliament and the courts, says the BBC's Ray Furlong.
Germany's strict migration laws mean that it has effectively been shut for decades to foreign workers from outside the EU.
Germany's ageing population means Chancellor Gerhard Schroeder's government
is battling to reduce the generous welfare state to cope with rising health care and pension costs.