Charging workers to bring claims against their employers in court has been ruled unlawful.
The Supreme Court, the UK's highest court, unanimously ruled in favour of an appeal brought by Unison against employment tribunal fees.
The fees, up to £1,200 in England, Scotland, and Wales, were introduced in 2013 under the coalition government by the then-lord chancellor Chris Grayling to prevent spurious or weak cases reaching court.
But unions including Unison claimed they were unlawful, and had led to a huge reduction in the number of cases being heard.
On Wednesday Supreme Court judges agreed, and also ruled that the fees were indirectly discriminatory against women.
In light of the ruling, the government will have to pay back the fees imposed since 2013, which Unison said were worth £27 million overall.
The union's general secretary Dave Prentis said the ruling showed the government was not above the law.
“The government has been acting unlawfully, and has been proved wrong – not just on simple economics, but on constitutional law and basic fairness too," he said.
Prentis added: “These unfair fees have let law-breaking bosses off the hook these past four years, and left badly treated staff with no choice but to put up or shut up."
The Labour manifesto for the 2017 general election had pledged to abolish the fees, and the party's MPs welcomed the court's decision.
Jason Moyer-Lee, head of the Independent Workers Union of Great Britain – which was an intervener in the case and has brought a number of separate gig economy test cases, including against Deliveroo – said that since the fees were introduced, there had been a 70% reduction in the number of cases brought.
"The government is going to have to reimburse all of the tribunal fees which have been paid since 2013, which is absolutely massive,” he told BuzzFeed News.
He said it would be up to the government to decide whether to entirely scrap or change the system of employment tribunal fees, but that "they are going to have to radically redo it if they want to introduce a new fee regime that is lawful".