The European Court of Human Rights has rejected a government attempt to overturn a ruling that prisoners should get the vote.
It has given Britain six months to draw up proposals for changing the law.
The court says this must happen according to a timetable decided by Europe's Committee of Ministers.
The government wants to overturn the court's decision that a convicted rapist had suffered a breach of his human rights when denied the vote.
But a panel of five judges has refused Britain permission to refer the ruling to the court's Grand Chamber, leaving ministers with no route for appeal.
A spokeswoman for the Cabinet Office said the government was disappointed with the decision.
It now has to decide how to reconcile the opinion of MPs, who voted in February by a large majority against giving prisoners the vote, with the demands of the court.
Under current UK law no sentenced prisoner is able to vote except those imprisoned for contempt, default or on remand.
The Committee of Ministers is the executive arm of the Council of Europe.