The Supreme Court has dismissed appeals from two prisoners over the right to vote under European Union rules.
Convicted murderers Peter Chester and George McGeoch had argued that EU law gave them a right to vote - even though they cannot under British law.
Prime Minister David Cameron told the Commons that the ruling was "a great victory for common sense".
The European Court of Human Rights has previously told the UK to end the blanket ban on prisoners voting.
Parliament is considering legislation, but has not yet decided what to do.
Following the Supreme Court's judgement, the BBC's legal correspondent Clive Coleman said: "Critically it ruled that EU law did not provide an individual right to vote, paralleling that recognised by the ECHR. Eligibility under EU law is a matter for national parliaments."
Convicted prisoners in the UK are banned from voting on the basis that they have forfeited that right by breaking the law and going to jail.
Successive governments have wanted to maintain that position but the European Court of Human Rights (ECHR) said a blanket ban on prisoners voting was disproportionate.
Peter Chester raped and strangled his niece in Blackpool in 1977 and was jailed for life for her murder. He has served his minimum term but the Parole Board has refused to release him because it says he is too dangerous.
In 2008, he tried to join the electoral roll so that he could vote in the elections for the European Parliament. The Ministry of Justice said he could not until the law was changed.
In the second case, George McGeoch, serving life in a Scottish prison, argued that EU law allowed him to vote in local and European elections.
Although the ECHR has already told the UK to change the law, these two cases focused on whether prisoners as EU citizens have a right to vote even if Westminster says differently.
Last year, the government conceded that it would have to change the law to allow some prisoners to vote.
Ministers have published a draft bill which is being considered by Parliament. The proposals include limiting the vote to inmates who are serving either less than six months or four years.
A further 2,352 inmates have tried to bring voting cases to the European Court of Human Rights. Those applications are adjourned while judges wait to see what Westminster does.