Judges at the European Court of Justice were asked to decide whether Germany could refuse unemployment benefits to so-called 'poverty migrants' under certain conditions.
Austria supported the German authorities in the case, which was prompted after a Romanian woman living in Leipzig applied for unemployment benefits and her local job centre refused when she didn't take up jobs they suggested to her.
However, the judgement will not have much of an impact on the current situation in Austria as there is already a law that means residency is only granted if migrants can prove they have the means to support themselves.
Migrants in Austria are only allowed to claim unemployment benefits after having worked full time for two years, and are able to prove that they are seeking work.
In the German case both the job centre and a court in Leipzig agreed that 25-year-old Elisabeta Dano, who moved to Germany in 2010 to live with her sister, had never really been looking for work.
But she appealed her case all the way to the European Court.
Now the EU court has said that states must have the right to refuse social benefits to unemployed migrants, a position supported by Austria.
The judges found that Dano did not have “sufficient means of support“ for herself and her 10-year-old son when she moved to Germany, and therefore couldn't justify her right to remain.
That also meant that she couldn't bring a case against the authorities based on EU anti-discrimination rules.
By agreeing that countries should be allowed to deny immigrants benefits under certain circumstances, the court followed the advice of experts whose testimony it had heard during the case.
They said that it should be legal to deny the applications of people who had travelled to a country with the sole purpose of claiming benefits.
The result will have significant consequences for the current EU-wide debate on freedom of movement.
In a statement Austria's Social Ministry said that Austria was already ahead of the rest of the EU when it came to regulating social benefits and that being a member of the European Union should not mean a "free ticket" to claiming benefits.
In 2013 101 EEA citizens were refused residence in Austria because they didn't have sufficient means to support themselves.
The European Court of Justice received submissions from Dano's lawyer as well as the German, Danish, Irish, French, Austrian and UK governments and the European Commission, the judges reported in their ruling.