David Cameron has hailed a European court ruling which appeared to support limits on the benefits that can be claimed by European nationals.

The Prime Minister described the judgement as "common sense".

The ruling comes at a sensitive time for the Conservatives on Europe - in just over a week the Tories face a crunch Westminster by-election against the eurosceptic UKIP.

Yesterday a new poll suggested UKIP still had a commanding 12 per cent lead, although the Tories were narrowing the gap.

Before yesterday's ruling the Tories had suffered a number of setbacks in Europe in recent weeks.

These include the outcry over the surprise bill for £1.7bn from Brussels a fortnight ago, as well as suggestions that Mr Cameron is becoming increasingly isolated on the Continent.

The ruling came in the European Court of Justice and involved two Romanians seeking out-of-work benefits in Germany.

The ECJ ruled that EU citizens were not entitled to all benefits and that this idea was consistent with the EU's cherished principle of freedom of movement.

Mr Cameron has suggested that he wants to clamp down on the benefits EU migrants can claim in the UK.

The Tory leader is expected to set out his plans in a keynote speech before Christmas.

But other European leaders have suggested that his proposals may prove incompatible with freedom of movement.

Speaking on the by-election campaign trail in Rochester in Kent, the Prime Minister said the ruling was "significant" and "welcome".

"This is a common-sense ruling. It's a good step in the right direction because, as I've said, the right to go and work in another European country should not be an unqualified right.

"There should be rules about restricting benefits and this is good news."

Iain Duncan Smith, the Tory Work and Pensions Secretary, also welcomed the judgment, saying it highlighted "what we have said for some time that free movement is not an unqualified right and will have a major impact on the way the Commission interprets law in future."

Whitehall sources suggested it was not immediately obvious to which of the UK's out-of-work benefits the new ruling would apply.

No 10 said that the Tory-Lib Dem Coalition Government would look "very closely" at the ECJ decision.

SNP MEP Alyn Smith said: "This judgment is a welcome blast of fresh common sense through the Westminster hothouse. We need a rational debate based on the facts and reality, not the half-baked truths of UKIP recklessly being repeated by the UK Prime Minister, demeaning his own office and cheapening the debate."

"The Dano case refutes the myth that anyone fresh off the plane can come here to abuse our social security system, it is simply not reality.

"The ruling makes it clear that member states can refuse to grant benefits to anyone who has moved to another country purely to seek social assistance."