HM Treasury has rushed through legislation to close down a high street bank's tax avoidance schemes. Photograph: Dominic Lipinski/PA

The Treasury has rushed in legislation to close down two "aggressive" tax avoidance schemes that a high-street bank had disclosed to HM Revenue and Customs in an effort to avoid tax.

As it announced highly unusual steps to take retrospective action to shut down the "highly abusive" schemes, the Treasury refused to the name the bank involved, although the Guardian understands that it is Barclays. The bank has refused to comment.

The government was immediately accused of making a "mockery" of its own code of conduct on tax – which 200 banks have signed to promise to comply with the spirit and not just the letter of the law – by refusing to identify the bank that the Treasury claimed would face a £500m tax bill.

The Treasury also said that the move would prevent "further billions of tax from being lost and maintain fairness in the tax system".

The detail was complex, but could have implications for any bank that is buying back its own debt – which has fallen in value because of the financial crisis – and making a profit as a result.

One of the schemes being shut down allowed the bank to avoid paying corporation tax on the profit it makes from buying back its own debt.

The second scheme involves authorised investment funds where the bank aims to convert non-taxable income into an amount carrying a repayable tax credit to secure a repayment from the exchequer even though tax has not been paid.

Barclays is among dozens of banks across Europe that have bought back debt – it started doing so on 5 December. The Treasury has said that the retrospective element of its changes would date back to the start of December.

The Treasury made clear that the bank had signed up to its code on conduct on tax. "The government is clear that these are not transactions that a bank that has adopted the code should be undertaking," a Treasury spokesman said.

But Lord Oakeshott, the Liberal Democrat peer, said last night that the Treasury's refusal to name the bank "made a mockery" of the code.

David Gauke, exchequer secretary to the Treasury, said: " We do not take today's action lightly, but the potential tax loss from this scheme and the history of previous abuse in this area mean that this is a circumstance where the decision to change the law with full retrospective effect is justified."