The government's "back to work" schemes, which were challenged by a graduate who was made to work for free at Poundland and an HGV driver made to clean furniture, were legally flawed, the UK's highest court has ruled.

The supreme court ruled against the Department for Work & Pensions (DWP), which was attempting to overturn an earlier verdict by the court of appeal.

The supreme court stopped short of ruling that the regulations constituted forced or compulsory labour, but said the 2011 regulations creating the programme were invalid as they did not contain a sufficiently detailed "prescribed description" of the schemes.

Geology graduate Cait Reilly, 24, who now works for the supermarket chain Morrisons, first disputed the government's employment schemes in January 2012 after working unpaid for Poundland over several weeks at pain of losing jobseeker's allowance.

The judgment would have resulted in the government having to refund £130m to about 250,000 unemployed people for unlawful sanctioning, had it not been for emergency retroactive legislation introduced by Iain Duncan Smith in the spring.

After the introduction of that emergency law, the solicitors Public Interest Lawyers (PIL), who represent Reilly and her co-claimant, Jamieson Wilson, an unemployed lorry driver, lodged a judicial review accusing Duncan Smith of conspiring to undermine basic human rights by enacting the retroactive legislation. They say they will continue to pursue that judicial review after their success in the supreme court.

In a statement outside the court, the lawyer Tessa Gregory said: "We are delighted that the supreme court has dismissed the government's appeal and confirmed that the regulations under which most of the 'back to work' schemes were initially created were unlawful.

"The court upheld the findings that Iain Duncan Smith acted beyond the powers given to him by parliament by failing to provide any detail about the various schemes. Iain Duncan Smith has sought to brand our clients as 'job snobs', but in reality all they have been seeking is a system that is fair and transparent."

After the ruling, Reilly said: "I feel very proud that people seemed to have realised there was an injustice going on, and that we have carried it on and reached the verdict today. It's quite unbelievable. I'm still getting my head around it. But it is a great result."

Reilly, a geology graduate from Birmingham, said the secretary of state needed to treat unemployed people with respect. "Jobseekers … are just trying to make something of themselves, like anyone else," she said. "We're not job snobs."

She added that for job-seeking to be made harder by poor DWP regulations was a terrible irony. "He [Duncan Smith] needs to realise they need to help us, not punish us," she said.

The DWP said it was disappointed that the supreme court had agreed with the court of appeal. It said it had dealt with the matter after introducing emergency legislation in March. Despite the fact that the legislation was subject to judicial review proceedings, it was "very confident" of its validity and would "defend it robustly".

Duncan Smith said: "We have always said that it was ridiculous to claim that our schemes amounted to forced labour, and yet again we have won this argument."

PIL said it would seek further legal action, and called on jobseekers to make claims against previous sanctions.

"We know that, like Jamie and Cait, hundreds of thousands of other jobseekers have not been, and continue not to be, provided with adequate information about the dizzying array of schemes," the lawyers said.

"Following today's judgment, any such jobseekers can object to sanctions that have been imposed and seek the repayment of their benefits.

"It is truly staggering that Duncan Smith has found himself in this position even after fast-tracking emergency retrospective legislation through parliament. We intend to work with advice organisations to ensure that, following this ruling, affected individuals have the right information and assistance."

eEmployment minister Esther McVey said: "All five judges unanimously said that the intention behind what we are doing is correct, mandation [mandating claimants into unpaid work] is correct. It is not what people have tried to say, it is slave labour. It is not at all.

"I'm pleased to say that the judges ruled on the side of common sense," she added.