The European Union’s top court ruled on Tuesday that EU nationals who move to another member state can be denied welfare payments, even if they have previously worked in their host country – but it said governments couldn’t expel people who could prove they were looking for work and had a chance of being hired.

The issue is central to the U.K.’s debate on EU membership. Britain’s Prime Minister, David Cameron, has frequently called for “wide-scale change to the rules on welfare and benefits” for EU citizens.

In...