Two convicted murderers who argued that European Union law gave them the right to vote in UK elections have had their appeals dismissed by the supreme court at Westminster.

Peter Chester, who is serving a life sentence in England, and George McGeoch, who is behind bars in Scotland, both tried to sidestep British legislation over prisoner voting rights, the European court of human of rights in Strasbourg having in the past ruled illegal Britain's voting ban for all those serving any sentence.

A parliamentary committee is considering whether to enforce the rulings or defy the European judges.

The supreme court justices observed that since Strasbourg had already declared the blanket ban on prisoners voting incompatible with human rights, there was no point in repeating it.

David Cameron welcomed the unanimous supreme court decision. The prime minister tweeted: "The supreme court judgment on prisoner voting is a great victory for common sense."

Chester, in his 50s, is serving life for raping and strangling his seven-year-old niece, Donna Marie Gillbanks, in Blackpool in 1977. He is detained at Wakefield prison in West Yorkshire; the minimum term he was ordered to serve before becoming eligible to apply for parole has expired.

McGeoch, from Glasgow, is serving his life sentence at Dumfries prison for the murder in 1998 of Eric Innes in Inverness. He received a minimum term of 13 years but owing to subsequent convictions, including taking two prison nurses hostage in a siege in 2001, will not be considered for parole until 2015.

Handing down the decision, Lord Mance said that in relation to both appellants' claims under EU law: "The provisions on voting contained in the applicable European treaties focus on the core concerns of ensuring equal treatment between EU citizens residing in member states other than that of their nationality, and so safeguarding freedom of movement within the EU. Eligibility to vote in member states is basically a matter for national legislatures."

The justices said that even if voting were to be extended to some prisoners, it was unclear that either McGeoch or Chester would necessarily benefit from a change to the rules, which could exclude prisoners convicted of more serious offences.

Lady Hale, deputy president of the supreme court, said: "Prisoners' voting is an emotive subject. Some people feel very strongly that prisoners should not be allowed to vote. And public opinion polls indicate that most people share that view."

Another justice, Lord Sumption, said: "In any democracy, the franchise will be determined by domestic laws which will define those entitled to vote in more or less inclusive terms.

"The exclusion of convicted prisoners from the franchise is not a universal principle among mature democracies, but neither is it uncommon."

Sumption said: "From a prisoner's point of view the loss of the right to vote is likely to be a very minor deprivation by comparison with the loss of liberty."

He said that the Strasbourg court had "arrived at a very curious position", noting: "Wherever the threshold for imprisonment is placed, it seems to have been their view that there must always be some offences which are serious enough to warrant imprisonment but not serious enough to warrant disenfranchisement. Yet the basis of this view is nowhere articulated."

The prime minister has vowed that inmates will not be given voting rights under his administration, and has said that the idea of giving prisoners the vote makes him sick.

He told the House of Commons last year: "No one should be in any doubt: prisoners are not getting the vote under this government."

Sadiq Khan MP, the shadow justice secretary, also welcomed the supreme court decision. He said: "Labour's policy is, and always has been, that prisoners shouldn't be given the vote. We believe that committing a crime so serious that a judge has deprived you of your liberty means you should also lose the ability to vote in elections."

The European court of human rights ruled in 2005, in the case of John Hirst, that a blanket ban on allowing serving prisoners to go to the polls was incompatible with the European convention on human rights (ECHR).

That court said it was up to individual countries to decide which inmates should be denied the right to vote from jail, but a total ban was illegal.

In November, the government published the voting eligibility (prisoners) draft bill for pre-legislative scrutiny by a joint committee of both houses. It set out three options: a ban for prisoners sentenced to four years or more, a ban for prisoners sentenced to more than six months and a restatement of the existing ban.

Sean Humber, head of human rights at the law firm Leigh Day, which represents more than 500 prisoners currently taking legal action through the ECHR, said: "Over the last decade, the European court of human rights has repeatedly found that the blanket ban on prisoner voting in the UK represents a breach of prisoners' human rights.

"The UK government remains morally and legally bound to take the necessary action to remedy the breach. David Cameron suggests that the prospect of giving prisoners the vote makes him feel physically ill. For a man with such an apparently delicate constitution, it is surprising that wilfully ignoring a succession of court rulings appears to have so little effect on him."