The European Union’s most senior court has ruled that it is lawful for countries such as Britain to impose a voting ban on prisoners convicted of serious crimes.

The unexpected ruling by the European court of justice upholds a ban on a French convicted murderer who was serving a sentence of more than five years from taking part in the European elections.

The European judges ruled that the ban on him voting did represent a breach of the EU charter of fundamental rights but that it was proportionate “in so far as it takes into account the nature and gravity of the criminal offence committed and the duration of the penalty”.

The ruling, which has clear implications for Britain’s blanket ban on prisoner voting, went on: “The court concludes that it is possible to maintain a ban which, by operation of law, precludes persons convicted of a serious crime from voting in elections to the European parliament.”

The French prisoner who brought the challenge, Thierry Delvigne, had been automatically banned from voting at the time of his conviction in 1988 under a law in force at the time which imposed a blanket ban on those sentenced to more than five years’ imprisonment.

The EU judges said that the ban to which “Delvigne was subject is proportionate”.

The law also allowed him to individually appeal against the decision to strip him of his voting rights. French law has since been changed to require individual prisoners to be banned by a court order which cannot be in force for longer than 10 years.

This first ruling by the most senior EU court comes exactly 10 years after the separate European court of human rights in Strasbourg ruled that a voting ban on a British prisoner, John Hirst, a convicted murderer, was unlawful.

David Cameron renewed his refusal on Tuesday to comply with the original 2005 Strasbourg ruling that a blanket ban on all prisoners was unlawful. “I haven’t changed my view at all. What’s happening today is a court case about a situation in France,” said the prime minister.

“Our own law has been tested recently and our supreme court opined that our law was right and that prisoners shouldn’t have the vote, and that’s my view. I’m very clear. Prisoners shouldn’t get the vote. It is a matter for the British parliament. The British parliament has spoken. The supreme court in Britain has spoken. So I’m content to leave it there.”

The original Hirst ruling in Strasbourg, which has been upheld by subsequent human rights rulings, made clear that it was the blanket voting ban on all prisoners that the judges regarded as breaching basic human rights.

It has always been open to the British government to end the blanket ban and replace it with a selective ban on certain categories of prisoners, such as the most serious criminals.

But when the government proposed legislation in 2010 to restrict the voting ban to those serving sentences of more than four years, a Commons vote by 234 to 22 made clear that MPs were not prepared to comply with the European human rights ruling.

Cameron has said that the idea of prisoners being given the right to vote makes him “physically sick”.

Britain is the only western European country with a blanket ban on prisoner voting with only Armenia, Bulgaria, Estonia, Georgia, Hungary and Russia in the Council of Europe imposing similar restrictions. Prison reform groups have argued that Britain’s ban has its origins in Victorian ideas of “civil death” being imposed on convicted prisoners.