The government has lost its final appeal against giving prisoners the right to vote following a ruling by the European court of human rights.

A five-judge panel said the UK must now draw up proposals within six months to end the blanket ban on prisoners voting. The court delivered the ultimatum after upholding its decision last November to award two UK prisoners €5,000 (£4,350) in costs and expenses for their loss of voting rights, which was ruled a breach of their human rights.

In February MPs overwhelmingly backed a motion calling for the maintenance of a blanket ban on prisoners voting, a move that apparently strengthened the government's hand as it sought to introduce the minimum possible requirements on voting rights for prisoners.

However, the court yesterday dismissed the government's request for an appeal hearing and decreed its original verdict final.

A statement issued by the court said: "The court now gives the UK government six months from 11 April 2011 to introduce legislative proposals to bring the disputed law in line with the [European Human Rights] Convention."

"The government is further required to enact the relevant legislation within any time frame decided by the Committee of Ministers, the executive arm of the Council of Europe, which supervises the execution of the Court's judgments".

More than five years ago the same court delivered a similar verdict in a separate case brought by a prisoner, but the then Labour government left the blanket ban in place despite publishing a timetable for legislation and issuing two consultation papers proposing different solutions.

Last November's second ruling, in which the Strasbourg court set a deadline of August 2011 for the introduction of UK legislation, came in a case brought by prisoners named as Robert Greens and MT, both serving time at Peterhead prison.

By then, the government had announced that it reluctantly accepted there was a legal obligation to offer voting rights to at least some prisoners, and scrap the total ban.

The minister for political and constitutional reform, Mark Harper, said at the time: "I think every member in the House is exasperated about this but we have no choice about complying with the law."

The next day, the prime minister told MPs: "It makes me physically ill to contemplate giving the vote to prisoners. They should lose some rights including the right to vote."

But Cameron said the government had to comply or face possible compensation claims running into millions in a flood of human rights claims by inmates.

A spokesperson for the Cabinet Office said last night: "We are disappointed with the court's decision. We will consider the next steps."

The UK is one of several European countries, including Armenia, Bulgaria, Estonia, Hungary and Romania, which automatically remove voting rights from sentenced prisoners, although remand prisoners still have the vote.

The human rights judges are not insisting that all prisoners have the right to vote, declaring only that it is a blanket ban on such a right that breaches the human rights code.

It leaves the government free to decide how to implement voting rights, for example by offering the right to vote to prisoners serving relatively short sentences, while maintaining a ban for long-term prisoners jailed for more serious crimes.

About 40% of the countries in the Council of Europe – which include 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, while Sweden, Switzerland and Denmark are among countries with no ban at all on voting for prisoners.

Ireland ended a voting ban five years ago, giving all prisoners a postal vote in the constituency where they would normally live.