The ruling was made in a case brought by Mohamed Ali Ben Alaya, a Tunisian student born in Germany. He left the country in 1995 to attend school in Tunisia.
After receiving his Baccalaureat in 2010, he was offered a place at the Technical University (TU) of Dortmund to study maths and applied to the German authorities for a student visa several times.
But the immigration authorities refused to allow him into the country, saying that his grades weren't good enough and he wouldn't have time to learn German to an adequate standard before the course began.
Ben Alaya brought his case to the Administrative Court of Berlin, which referred it to the Court of Justice of the European Union in Luxembourg.
Now the European Court has decided that he should have been allowed to study in Germany in a ruling which could have implications for all foreign student hopefuls.
“This decision is very welcome,” Johannes Glembek, director of the Foreign Students Federation (BAS) told The Local.
“We are constantly receiving more reports of students being turned away because their studies seem implausible to the authorities, because of their age or because of their level of language," Glembek said.
"In one case, a Pakistani man was denied entry because they decided the master programme he wanted to study didn't match his bachelor. How are they qualified to make that judgement?"
In Ben Alaya's case, the Berlin court wanted to know if the authorities were still allowed to refuse his visa even though he fulfilled all the minimum requirements laid out by a 2004 European Commission directive on students from outside the EU.
Border officers have until now been allowed to make their own decisions even when applicants fulfilled all the minimum criteria to be considered.
But the European Court found that if a student met the conditions in the directive, they must be issued a visa, unless they pose a “threat to public policy, public security or public health”.
The directive was issued “in the context of a strategy designed to promote Europe as a whole as a world centre of excellence for studies and vocational training.”
This meant it wouldn't make sense to allow individual countries carte blanche to refuse students access, Advocate General Paolo Mengozzi said in a preliminary legal opinion published by the court in June.
"The government has taken note of the decision of the Court of Justice of the European Union," the Foreign Ministry said in a statement. "The government will check the decision... with a view to how it can be implemented in German administrative practice."