Thousands of social housing tenants have been wrongly hit by the so-called bedroom tax and are in line for money back, it has emerged.

A loophole in the Government's welfare reforms means what ministers call the spare-room subsidy does not apply to certain renters who have lived in the same home for more than 17 years.

Housing experts told the Guardian 40,000 claimants could be affected but the Department of Work and Pensions has stressed that it believes a maximum of 5,000 tenants are likely to have been caught up.

It has written to local authorities alerting them to the glitch and insists new regulations will be introduced swiftly to rectify the oversight.

Shadow welfare reform minister Chris Bryant told the Guardian: "This is the latest example of the chaos and confusion within the Department of Work and Pensions under Iain Duncan Smith.

"Rather than closing loopholes in the policy, the Government should scrap their hated bedroom tax. If they don't, the next Labour government will."

Under the Government's welfare reform, social tenants deemed to have more bedrooms than they need have had their housing benefit reduced.

Ministers say private sector renters do not get spare rooms for free, and argue the change will save around £500 million annually.

But it has sparked protests across the country with opponents claiming it is forcing families into poverty and will increase the benefits bill by pushing people into the private sector.

The error affects tenants in social housing on housing benefit whose claim has not changed since before 1996 as they are covered by old regulations, which were mistakenly left unchanged under the Government's reforms.

It could amount to a refund of at least £640 per claimant, according to the Guardian.

Joe Halewood, an independent housing consultant, said estimates that 40,000 people were affected were based on projections following information from Exeter City council, which has found that 4.5% of those hit by the penalty were wrongly held liable.

He told the Guardian's housing network website: "Forty thousand is actually a conservative estimate. You're looking at one in 25 of housing benefit claimants being affected."

A DWP spokesman said:‬ ‪"We are looking at this issue carefully and working with local authorities, and we will take any necessary action in due course. We expect very few people to be affected."‬