Iain Duncan Smith’s nemesis has never sat on the green benches of parliament. In fact, he has never met the Work and Pensions Secretary at all.

But Peter Barker, a 53-year-old self-confessed anorak from Romford, Essex, made a discovery that is likely to cost the minister millions. He found a loophole in the so-called bedroom tax which could mean that up to 40,000 housing benefit claimants can claim money back.

Overall the controversial policy affects around 660,000 housing benefit claimants who are deemed to have one or more “spare” rooms and have between £14 and £22 a week deducted from their benefits.

Download the new Independent Premium app Sharing the full story, not just the headlines

Tenants who have occupied the same property continuously and taken housing benefit for it since 1996 should never have been included in the policy, Mr Barker discovered. When the Department for Work and Pensions drafted the controversial legislation it did not update housing benefit regulations dating from that year.

Those affected include some who are facing eviction because of the bedroom tax- or who have been forced to move to smaller properties.

Mr Barker, who is a consultant on housing policy, put up his findings on a blog called Rights Net and it instantly went viral. Now more than 10,000 people have viewed it - rather more than his usual blog audience of “two or three hundred”.

Last week the Government conceded that Mr Barker was onto something, issuing a circular telling councils that exempted tenants should be refunded all money deducted under the policy since 1 April.

The victory still elicits a proud grin. “I’m delighted, particularly with the way the numbers are playing out,” he says. “My gut feeling was the numbers affected would be in the thousands, but now it’s clear it’s going to be tens of thousands.”

“If it was up to me I’d abolish the bedroom tax immediately. There are far fairer ways of saving far more money. They must be able to find better ways of cutting the welfare bill than winkling people out of homes that they have lived in, in some cases, for decades.”

The bliss at his discovery was short-lived, however. Speaking in the House of Lords on Tuesday, Welfare Reform minister, David Freud, said that the rules will be amended in March “to ensure that all working-age social sector tenants who under-occupy their homes are subject to a reduction in their eligible rent, regardless of the length of their tenancy, unless they fall within one of the limited exceptions.”

Inside Politics newsletter The latest news on Brexit, politics and beyond direct to your inbox Enter your email address Continue Continue Please enter an email address Email address is invalid Fill out this field Email address is invalid Email already exists. Log in to update your newsletter preferences Register with your social account or click here to log in I would like to receive updates on politics every morning by email Update newsletter preferences

Despite Mr Barker’s excitement being “tinged with slight regret that they’re going to close the loophole", he is pleased that tenants will be able to claim back a year’s charges, likely to be at least £640 per claimant.

Speaking to The Independent in the lobby of a central London hotel where he runs courses on housing benefit appeals, Mr Barker is evangelical about making the increasingly combative benefits system work in favour of vulnerable claimants.

Almost all of those enrolled on his course work for local authorities. He says council staff are often eager to help people avoid the charge: “A lot of local authorities have their heart in the right place and I’m trying to demonstrate ways of upholding appeals that they might not be aware of”.

Mr Barker first started advising people on benefits in the Eighties, working for the Citizens Advice Bureau. He has personal experience of helping people work the system in their favour from the inside. In his previous job as an appeals officer for a local authority, he says he was “notorious for being soft on judgement calls and tending to err on the claimants’ side”.

His latest class of 14 is made up almost entirely of local authority appeals officers and one housing association tenant adviser. He says local authority staff are often eager to find ways of helping people wriggle out of the bedroom tax.

“Amongst local authorities there is overwhelming opposition to the bedroom tax”, he says. “I haven’t found anyone working for a local authority who’s enthusiastic about it. That goes across political lines; it’s an issue that’s united people who wouldn’t normally be in agreement.”

As if to confirm this sentiment, his local authority students, who are waiting to go back into lectures, are eager to distance themselves from the Government policy.

One says: “They’re people, these residents. I want them to win their appeals because it’s their lives.”

“It’s been rushed through for popularity, rather than thought through,” says another, “It’s to appeal to voters because they’re starting to demonise those on benefits”.

Another council worker, who also wanted to remain nameless, said: “Local authorities feel all these changes have punished us and made our jobs a lot harder. There’s a real shortage of one bedroom houses now - everything they’ve done is act now, think later”.

Though it was Barker who made the loophole public, he has an unnamed Scottish judge to thank for noticing its potential.

He was approached by someone working for a Local Authority in Scotland - whose identity he is protecting - wanting advice. “She asked me about a strange request from a tribunal judge who wanted to know whether the appellants had been on Housing Benefit in the same property since 1996.”

“I started to look into the legislation and realised the judge was onto something.” It was after that he decided to share the information online.

Though housing benefit experts have estimated the number eligible for a refund as a result of the loophole is likely to be between 20,000 and 40,000, DWP insists it will only affect a small number of tenants, estimating a number closer to 5,000.

A DWP spokesman said: “The removal of the spare room subsidy is a necessary reform that will return fairness to housing benefit. Even after the reform, we still pay the majority of most claimants' rent, but the taxpayer can no longer afford to pay for spare bedrooms.”

Despite the embarrassment he has caused in Government, Mr Barker insists the discovery was not political. “It’s had political ramifications but it was a fairly geeky technicality,” he says.

And what does he think the next policy loophole will be? Looking suddenly determined, he replies: “I’m still looking”.