LUXEMBOURG (Reuters) - The European Union’s highest court on Thursday upheld a Spanish judge’s refusal to let a Moroccan resident bring his wife to join him because he had failed to show he would earn enough to support them both.

In a judgment that joins others in the past two years in restricting migrants’ rights as Europe deals with a surge in immigration, the European Court of Justice said the Spanish ruling was consistent with an EU law that gives long-term, non-EU residents an entitlement to “family reunification”.

“The directive allows the member states to demand proof that the sponsor has stable and regular resources which are sufficient to maintain himself and the members of his family, without him having to have recourse to the social assistance system,” the ECJ said in a statement on the ruling.

Mimoun Khachab, a Moroccan with a long-term Spanish residence permit, asked in 2012 that his wife too be granted residence. Spanish authorities turned that down on the grounds, among others, that he worked for only 48 days the previous year and was unlikely in the coming year to earn enough to live on.

One issue raised in the case was whether authorities were entitled to forecast his future earnings, from working for building firms and as a fruit picker. The EU judges ruled that they were.

As well as Spain, the German, French, Dutch and Hungarian governments submitted observations on the case to the judges.

The Court has recently underlined a link between economic resources and immigrants’ rights in cases involving EU citizens moving to other European states and claiming welfare benefits.

Immigration is fuelling hostility to the European Union in many countries, notably in Britain which is holding a referendum in June on whether to quit the bloc, and EU officials have been keen to emphasize the legal limits that exist on migration.