The government faces a £4bn a year pensions bill after a group of judges and firefighters won an age discrimination court case, it has emerged.

One investment firm said members of public sector pension schemes could receive a massive boost to their retirement pots if the government’s appeal against the court decision was unsuccessful. That might need to be financed through cuts in spending or increases in taxes.

The coalition government pushed through a series of changes that meant most public sector workers were moved to new pension schemes in 2015. However, these new schemes typically offered less generous terms, prompting anger among many workers and unions.

As part of the changes, the government put in place transitional arrangements which typically meant older workers could stay in the existing, more generous schemes, while younger workers had to transfer to the new schemes.

A group of judges and a group of firefighters decided to take the row to court, and on 20 December the court of appeal ruled that the transitional arrangements offered to some members amounted to unlawful discrimination.

Now the government has spelled out the potential cost of this ruling. On Wednesday, Liz Truss, the chief secretary to the Treasury, said in a written statement: “The provisional estimate is that the potential impact of the judgment could cost the equivalent of around £4bn per annum.”

She said the government was seeking permission to appeal the decision, and if this was unsuccessful, employees who were transferred to the new schemes would be compensated.

The investment firm Hargreaves Lansdown said the judgment was expected to have an impact on other public sector groups, such as police officers, who had seen similar changes to their pension schemes and would also extend to public sector workers such as those employed by the NHS, teachers and prison officers.

Tom Selby, a senior analyst at investment firm AJ Bell, said: “Members of public sector schemes could receive a massive boost to their retirement pots if the government’s appeal against this decision fails. This boost will come at a cost to the Treasury – and taxpayers in general – of somewhere in the region of £4bn a year.”

He said the implications for the public finances “are potentially gargantuan”, adding: “It is highly unlikely [this] could simply be absorbed by the exchequer, so cuts in spending or increases in taxes will almost certainly be needed to fill this pensions black hole.”