A gay man has won a Supreme Court battle to secure equal pension rights for his husband.

The Supreme Court justices ruled that Mr Walker’s husband is entitled on his death to a spouse’s pension, provided they stay married.

The landmark ruling means his husband is entitled to the same benefits as a wife would be.

Pensions law previously left some married gay and lesbian couples worse off than their heterosexual counterparts – because same-sex couples have only been recognised in the eyes of the law since civil partnerships were introduced in 2005.

The loophole meant that while elderly straight couples have had decades to accrue rights to partner benefits on private pension plans, a number of plans only offer entitlements from 2005 onwards to gay and lesbian couples.

66-year-old John Walker challenged rules that meant he would only be entitled to pass £500 of his final salary pension on to his husband and partner of more than 30 years when he dies – compared to £41,000 that a female widow could claim.

Responding to the ruling, John Walker said: “I am absolutely thrilled at today’s ruling, which is a victory for basic fairness and decency.

“Finally this absurd injustice has been consigned to the history books – and my husband and I can now get on with enjoying the rest of our lives together.

“But it is to our Government’s great shame that it has taken so many years, huge amounts of taxpayers’ money and the UK’s highest court to drag them into the 21st century.

“In the years since we started this legal challenge, how many people have spent their final days uncertain about whether their loved one would be looked after?

“How many people have been left unprovided for, having already suffered the loss of their partner?

“What I would like from Theresa May and her ministers today is a formal commitment that this change will stay on the statute books after Brexit.”

Emma Norton, Liberty lawyer acting for Mr Walker, said: “We are delighted the Supreme Court recognised this pernicious little provision for what it was – discrimination against gay people, pure and simple.

“But this ruling was made under EU law and is a direct consequence of the rights protection the EU gives us.

“We now risk losing that protection. The Government must promise that there will be no rollback on LGBT rights after Brexit – and commit to fully protecting them in UK law.

“How else can John be sure he and others like him have achieved lasting justice today?”

Same-sex couples outraged at the ‘short-changing’ have long been trying to re-address the rules.

The case was defeated at the Court of Appeal in 2015, prompting Mr Walker to take his case to the Supreme Court.

Responding to the decision a Government spokesperson said: “We are reviewing the implications of this judgement in detail and will respond in due course.

“The rights of same sex couples have been transformed for the better since 2010 including the introduction of same sex marriage and legislation to ensure that pensions are built up equally for all legal partnerships.”

Alastair Meeks, pensions partner at Pinsent Masons, said: “The Supreme Court has surfed on the fast-changing social currents to consign to the scrapheap a compromise established a dozen years ago on the introduction of civil partnerships.

“At the time the compromise was not particularly remarked upon as unfair, but now it looks distinctly out of date to many.

“The Supreme Court used principles of EU law to strike down UK statute. In these days of Brexit, that will attract attention. It is unlikely in practice that post-Brexit any government would seek to reverse this decision, even if it could. But it does suggest that the law might develop very differently from how it would otherwise develop once Britain has left the EU. Social changes might well take considerably longer to work their way through into legal consequences.”