Royal Bank of Scotland tied up at least £25bn in complex international tax-avoidance schemes during its boom years, costing the British and US treasuries more than £500m in lost revenue, the Guardian can disclose.

It is the first time that a major bank has admitted the existence of such deals on this scale. The new management at RBS, mindful of the fact that it is now 70% owned by the taxpayer, has disbanded the department responsible and will put an end to the controversial practice.

"The idea that we could take support from the Treasury with one hand and somehow pick their pocket with the other would be wrong on every level. We have always sought to avoid this sort of stance and that's more important now than ever. It's not a sustainable way to do business," said an RBS source.

The previous management, led by Sir Fred Goodwin - who is now retired with a £700,000-a-year pension - presided over a massive expansion of so-called "structured trades". These are huge deals across national borders, to make profit out of tax avoidance. They are not illegal, but secretively exploit gaps in different countries' tax laws.

The Guardian has identified at least 13 such deals, many using the offshore facilities of the Cayman Islands, in the Caribbean, in ingenious ways.

The deals involved "investments" of as much as £6bn at a time. The cash was moved in circles between RBS and other banks. One former British official close to the US revenue's intelligence efforts said tax deals such as this were an important factor in driving the "securitisation" boom which led to the worldwide financial calamity.

Banks enthusiastically bought huge tranches of so-called mortgage-backed securities as part of tax deals.

The British official said: "Mega tax-avoidance schemes demanded the movement of mega funds. The web of notes passing between banks to effect avoidance schemes was so big and complex that no-one knew quite what they had.

"The profit is actually only a tax relief and the underlying reality of many of these deals was a loss."

The new management of RBS has promised that such activities will now stop. This is partly because the enormous sums of capital required have dried up, and partly because the bank recognises it is now dependent on taxpayer support.

An RBS spokesman told the Guardian: "We have always sought to maintain an open, constructive and transparent relationship with [HM Revenue and Customs] as befits an institution of our size and importance to the UK economy and exchequer.

"This is even more important now given the level of UK taxpayer support for our business as we restructure."

The team behind RBS's "structured trades" has been largely disbanded. Johnny Cameron, who headed its stricken Global Markets operation, has departed, with a pension of £62,000 a year.

Tim Pettit, global head of the financial structuring group, whose name was on many of these structured trades, has now moved to another position within RBS.

But industry sources say the government has so far failed to make giving up tax avoidance a general condition of providing taxpayers money to help bail out Britain's banks.

Lloyds, despite accepting toxic asset insurance that will take the state's share of the bank to 77%, would not respond when asked if it will promise to abandon similar trades, which have totalled £4bn. Lloyds is currently fighting the UK government in court over a tax-avoidance scheme.

According to insiders, Barclays Bank has been the biggest structured finance tax avoider, regarded as "high-risk" by HMRC. Barclays has sought so far to survive without government intervention.

The US treasury appears to have been the tax loser in many of these RBS deals. President Barack Obama has already personally vowed to crack down on the British-controlled Cayman Islands in the present international campaign against tax havens.

Jack Blum, a Washington lawyer who is a frequent expert witness to Senate tax investigations, said: "We've seen several cases of US banks working with UK banks to make a profit from tax avoidance for both of them. It's very hard to ferret out unless someone confesses."

The essence of many of the RBS deals is so-called "double-dipping". Tax losses end up in secretive offshore entities with ambiguous or dual corporate status, and then both RBS and a foreign partner claim tax reliefs from the same deal.

The foreign counterparties in the RBS deals include some of the biggest names in international finance - the troubled US insurer AIG, the now part-nationalised Dutch-Belgian bankers Fortis, insurers Swiss Re, and the US investment banks Morgan Stanley, Merrill Lynch, and Goldman Sachs.

A number of the transactions had been halted over the past five years by changes in either UK or US tax law. But Treasury sources told the Guardian that although HM Revenue and Customs were aware of the RBS deals, they were only in the early stages of studying them.

More recent deals appear to have become more creative in response to crackdowns.