Human rights judges today gave David Cameron six months to honour the coalition Government's pledge to give prisoners the vote.
The ultimatum was announced in Strasbourg after the European Court of Human Rights ruled in an Italian case "it is up to member states to decide how to regulate the ban on prisoners' voting".
The judges said today's decision amounted to confirmation of a ruling against the UK in 2005 that a blanket ban on all serving prisoners losing voting rights is a breach of their human rights.
The UK was given nine months to introduce at least partial voting rights for some prisoners in November 2011, but has not done so.
The deadline was extended after the UK authorities asked to make legal submissions in the Italian case, and a new six-month deadline is triggered with today's ruling.
But the Human Rights Court said it now accepted the UK government argument that "each State has a wide discretion as to how it regulates the ban, both as regards the types of offence that should result in the loss of the vote and as to whether disenfranchisement should be ordered by a judge in an individual case or should result from general application of a law."
The wrangle with Strasbourg began when UK inmates complained that the loss of voting rights violated a Human Rights Convention Article guaranteeing the "right to free elections".
The court twice decreed the UK's total ban on votes for prisoners to be illegal.
But the Labour government left the ban in place, and Tory inaction despite a second ruling in 2010 angered civil liberties groups.
Last autumn Minister for Political and Constitutional Reform Mark Harper told the Commons that the coalition reluctantly accepts that the UK has a legal obligation to fall in line, but has not yet decided which inmates it would affect.
Mr Cameron was more direct a day later, telling MPs: "It makes me physically ill to contemplate giving the vote to prisoners. They should lose some rights, including the right to vote."
Today's Italian case raised hopes that the judges might modify their original verdict, and UK lawyers were allowed to make submissions defending the UK stand.
The resulting ruling decided that the loss of voting rights of a convicted killer in Italy did not breach his human rights.
But the judges emphasised that that was because in Italy, unlike the UK, there is no "general, automatic, indiscriminate" ban in place of a kind which produced the 2005 ruling against the UK.
By the time of the second ruling against the UK in November 2010, the judges went on, there were about 2,500 similar pending applications lodged with the human rights court by UK inmates - with the number continuing to grow.
If the UK complies with the ruling to grant some prisoners voting rights within the new six-month deadline triggered today, the Human Rights Court would strike out all similar pending cases.
That would remove the threat of massive potential Government damages payments to prison inmates if all complaints went through the courts and were upheld.
The original UK case on 2005 was a landmark victory for convicted killer John Hirst from Hull.
In the November 2010 case, two prisoners, named as Robert Greens and MT, both serving time at Peterhead prison, were awarded 5,000 euros in costs and expenses for their loss of voting rights.
Today's declaration on the implications for the UK of the latest Italian ruling said the judges had not thought it appropriate to give the UK authorities guidance about the content of future legislative proposals on prisoner voting rights, as that was a decision for the Government.
But it issued a deadline for amending the law, and that had been put on hold until after the Italian ruling.
About 40% of the 47 countries covered by the Human Rights Convention - including all 27 EU member states - have no restrictions on prisoners voting.
Others ban only some sentenced prisoners from voting. In France and Germany, courts have the power to impose loss of voting rights as an additional punishment.
The UK is among a few European countries, including Armenia, Bulgaria, Estonia, Hungary and Romania, which automatically remove voting rights from sentenced prisoners, although UK remand prisoners still have the vote.
A Downing Street spokeswoman said the Government would consider the implications of the ruling for the UK before responding.
The spokeswoman said: "This is a judgment affecting Italy, but clearly we need to consider the implications of that judgment on the issue of prisoner voting for the UK.
"The position for the UK is that the Attorney General has argued that the issue of social policy, including prisoner voting, is a matter for Parliament and it is for Parliament to judge whether and which prisoners should have the vote, and that the court should not interfere with that judgment unless it is manifestly without reasonable foundation."
A Cabinet Office spokesman said: "This is a judgment which is for the Italian government to implement. But we will consider it carefully, and its implication on the issue of prisoner voting in the UK."
In today's ruling, the judges said the rights to free elections guaranteed by the Convention were "crucial to establishing and maintaining the foundations of an effective and meaningful democracy governed by the rule of law".
But those rights were not absolute and governments had "a margin of appreciation in the limitations they applied to them".
They said that UK lawyers argued during the Italian hearing that the ruling in the UK case of John Hirst was wrong.
But, said the judges, "nothing seemed to have changed" that would justify re-examining the Hirst case - "on the contrary, if anything, the trend was towards fewer restrictions on convicted prisoners' voting rights".
The judges then reaffirmed their Hirst decision - "in particular, the fact that when disenfranchisement affected a group of people generally, automatically and indiscriminately, based solely on the fact that they were serving a prison sentence, irrespective of the length of the sentence and irrespective of the nature or gravity of their offence and their individual circumstances, it was not compatible with Article 3 (of the Human Rights Convention)".
The ruling pointed out that in Italy the loss of voting rights applied only to prisoners guilty of certain types of offences and where a sentence of at least three years was imposed.
That meant a large number of convicted prisoners in Italy were not deprived of the right to vote in parliamentary elections.
And even for those affected, the right to vote was restored three years after the sentence was completed and it was possible for a convicted individual "who had displayed good conduct" to apply for rehabilitation and recover the right to vote.