UBS Group AG and HSBC Holdings Plc — two of the banks hardest hit amid a U.S. crackdown on customers’ illicit funds in recent years — are now starring in a torrent of leaked documents detailing how they once helped clients set up thousands of offshore shell companies.

A report late Monday by the International Consortium of Investigative Journalists, drawing on 11.5 million records extracted from Panama-based law firm Mossack Fonseca, describes the contortions UBS and other banks went through as they struggled to distance themselves from clients’ offshore companies amid mounting U.S. scrutiny. It also shows how European banks in particular had once helped customers create those entities: HSBC and its subsidiaries accounted for more than 2,300 of the shells registered through Mossack Fonseca, while UBS and Credit Suisse Group AG were behind more than 1,100 apiece, according to the ICIJ report.

While the use of offshore companies can be perfectly legal, the documents have ignited a global debate since they came to light on Sunday, exposing the extent to which politicians, business leaders and celebrities make use of a secretive financial ecosystem. The scandal is a fresh headache for banks, some of which have paid billions of dollars in fines in recent years, promised to fix controls and dismantled once-lucrative businesses as they try to put to rest accusations they harbored money for tax dodgers or criminals.

“Banks and professional organizations including accountants and lawyers need to up their game in relation to knowing who their ultimate clients are,” said Alan Sheeley, head of the civil fraud and asset recovery team at Pinsent Masons law firm in London. It also raises pressure on governments, he said.

In 2010, as UBS was trying to deal with a U.S. Department of Justice investigation into illegal tax shelters, the Zurich-based bank sought to pull back from the shell companies, according to the ICIJ report. In a meeting that year with Mossack Fonseca, the bank’s representatives asserted the law firm should be responsible for identifying the shells’ owners, while the law firm insisted it didn’t know who some of them were because the bank had withheld the information, according to the report.

‘Special Treatment’

The two sides eventually figured out a way forward: Mossack Fonseca would take over the administration of the shell companies established by UBS clients and accord them “special treatment,” ICIJ said. Under the new system, Mossack Fonseca agreed to accept lighter due diligence from UBS on those clients, requiring less documentation on the owners and why they used shell companies, ICIJ reported.

Following the leak, regulators across Europe announced probes into the offshore activities of the banks they supervise. Swedish regulators have summoned Nordea Bank AB, Scandinavia’s biggest lender, to answer questions on assistance it allegedly provided to wealthy clients to help them evade taxes. Austria’s Finanzmarktaufsicht watchdog will probe the procedures Raiffeisen Bank International AG and Hypo Vorarlberg use to prevent money laundering after they were implicated in the scandal. Switzerland’s Finma will “clarify” the extent to which its banks dealt with Mossack Fonseca and whether they violated banking supervisory rules.

A Mossack Fonseca spokesman told the journalist consortium that it conducts “thorough due diligence on all new and prospective clients that often exceeds in stringency the existing rules and standards to which we and others are bound.” Many of its clients come through reputable financial institutions, which are bound by so-called know-your-customer laws, the group quoted her as saying.

Asked about details of the ICIJ story, UBS spokeswoman Marsha Askins said the bank decided to end the relationship with the law firm years ago.

“Your question refers to services concerning the set-up and administration of offshore companies using third-party providers which UBS proactively decided to discontinue in 2010,” she said in a written statement. “This process happened in stages and has been completed.”

Credit Suisse Chief Executive Officer Tidjane Thiam said the bank conducted business in full compliance with applicable law and regulations.

“We only accept offshore structures, vehicles if they serve legitimate purposes. Clearly, tax avoidance is not one of those,” Thiam said in an interview Tuesday in Hong Kong with Bloomberg Television. “We insist on knowing who is the beneficial owner. If it’s not revealed, we will not engage in business with that entity.”

He declined to comment specifically on the leaked documents or on his bank’s interactions with regulators.

HSBC, in a statement, said it works closely with authorities to fight financial crime and implement sanctions. Its shares were down 2.7 percent to 419 pence at 11:18 a.m. in London, the lowest level in seven years.

“Our policy is clear that offshore accounts can only remain open either where clients have been thoroughly vetted (including due diligence, ‘know your customer’ source of wealth, and tax transparency checks), where authorities ask us to maintain an account for the purposes of monitoring activity, or where an account has been frozen based on sanctions obligations,” the bank said.

Journalists working with the consortium pored through millions of pages of documents leaked from the law firm to piece together what they alleged was a global web of shell companies that helped hide wealth of world leaders and criminals, among others. The records outlined the creation of more than 200,000 offshore companies in all, according to the ICIJ. Almost 15,600 shells were registered by more than 500 banks in recent decades, according to its analysis.

While companies that shield owners’ identities can be used legally, they can also be tools for hiding assets, laundering funds or evading taxes. The U.S., among other countries, require banks doing business in the country to perform certain levels of due diligence on their clients to understand who the beneficial owners of such structures may be.

Complicating Relations

Still, the revelations may complicate relations between banks in developed nations and those in still developing countries, said Peter Hahn, a professor at London’s Institute of Financial Services.

“Leading bank chairs and CEOs will have a tough night’s sleep worrying and wondering about whether their organization have touched these deals regardless of whether their activities were legal or not or how long ago they happened,” Hahn said.

As of now, regulators haven’t accused the banks of any wrongdoing related to their business with the Panamanian law firm. Still, the disclosures could be problematic for HSBC, which entered into a deferred-prosecution agreement with the U.S. Justice Department in 2012, paid $1.9 billion and admitted to conduct that violated U.S. sanctions laws and anti-money laundering statutes.

UBS and Credit Suisse are in a similar spot. Last year, a UBS unit pleaded guilty to one count of wire fraud related to the manipulation of benchmark interest rates. Credit Suisse pleaded guilty in 2014 to helping U.S. citizens dodge tax payments. As part of their settlements with the Justice Department, the banks pledged full cooperation with any investigation into other possible misconduct.

In 2009, UBS paid $780 million to avoid prosecution in the U.S. for helping Americans hide money in Swiss bank accounts. It paid about 300 million euros ($341 million) in 2014 to settle a similar probe in the German state of North Rhine-Westphalia.

’Proactive Policy’

Societe Generale SA accounted for 979 offshore companies set up through Mossack Fonseca, according to the ICIJ. The bank said in a statement Monday that it has ‘‘a proactive policy with regard to the fight against fraud and tax avoidance.”

Two other banks listed in the report — Experta Corporate & Trust Services SA and Coutts & Co. Trustees — also denied any wrongdoing. Experta said it’s investigating the basis for the allegations and that when it helped clients set up offshore structures for wealth-planning purposes, it was “within the existing national and legal frameworks.”

Coutts said it is committed to the highest standards of regulatory compliance, including tax laws, anti-money laundering regulations and international sanctions. “We require all clients to be tax compliant as a condition of receiving our products and services,” it said.