Treasure, in fairytales, is stored underground and guarded by gnomes. The gnomes of Zurich have over the years performed heroically. They have succeeded in protecting from the world's tax authorities nearly a third of the world's $7 trillion of privately held wealth.

But against their will, Swiss bankers are being dragged from subterranean vaults into the light. The fairytale that has delivered a standard of living envied by the rest of the world is slipping away. And the country's power brokers know it.

Last Tuesday, on the day Switzerland's biggest bank, UBS, saw its share price sink to an all-time low, the country's president, Hans-Rudolf Merz, himself a former UBS banker, suggested for the first time that bank secrecy - his country's most precious commodity - is no longer non-negotiable.

A historic moment, it was followed a day later by the sudden resignation of the chief executive of UBS, once its richest institution. The departure of Marcel Rohner, who lasted just 20 tempestuous months, is yet another calamitous milestone in the collapse of what is arguably Europe's most powerful bank.

For Switzerland, these are dark days. Private banker to the world, the country - and in particular its shadowy financial elite - has suffered a wave of unprecedented humiliations.

No European bank has suffered bigger write-downs than UBS. Its reputation for risk-free sobriety in shreds, UBS has dumped $40bn worth of toxic sub-prime mortgages and CDOs into a "bad bank" and required a $3bn government bail-out. It has even been forced to order bankers to hand back bonuses after the traditionally phlegmatic Swiss public reacted with fury when it realised UBS was doling out $2bn to loss-making money-men.

Even more damagingly, UBS is embroiled in a multi-million-dollar tax evasion scandal in the United States that has led to the bank being sued by the US Department of Justice, which is demanding the identities and details of 52,000 of its American account holders. The future of Swiss banking hangs on this case.

Two weeks ago, UBS paid a $788m fine and handed details of 250 private accounts to US investigators after court documents revealed that UBS wealth managers smuggled diamonds in toothpaste tubes, deliberately destroyed offshore bank records on behalf of clients and assisted wealthy Americans to conceal ownership of their assets by creating "sham" offshore trusts. Misleading and false documentation was routinely prepared to facilitate this.

The motivation, according to a former senior UBS executive who last year entered into a plea bargain to reduce his sentence, was to ensure the bank managed a staggering $20bn of assets owned by wealthy US individuals, which generated the bank $200m in fees each year. The scandal has seen a huge outflow of funds from UBS since it broke last summer and sparked a wave of litigation against the bank from wealthy clients furious at having their identities revealed.

Switzerland is now an international whipping boy. This year it suffered the indignity of being refused an invitation to the international G20 conference to be held in London in April to discuss reforms to the global financial system - despite a plea by president Merz, who doubles as his country's finance minister, to Gordon Brown at the World Economic (WEF) meeting in the Swiss ski resort of Davos at the end of January. For the world's seventh largest financial centre, the snub is more than an embarrassment. It means the country has become neutered, unable to influence events that could shape globalisation for decades to come.

The problems have led the country's justice minister, Eveline Widmer-Schlumpf, to fly to Washington next week to talk to her American counterpart in a desperate bid to resolve the escalating legal dispute between the two countries.

The mainstream Swiss business community is praying for a breakthrough. Switzerland has also spawned some of the world's biggest non-banking corporations, including food giant Nestlé; Roche, the pharmaceuticals firm; and Glencore, one of the world's most powerful mining companies.

Mindful of the harmful ramifications of the tax scandal, leading executives appear to be backing a form of financial glasnost to counter the threat of being isolated on the world stage. Johann Schneider-Ammann, a board member with many of Switzerland's leading firms, an industrialist and an influential political figure, said last week that tax evasion should be treated as a crime. In Switzerland, this is a revolutionary statement. What makes it unique as a major European country is its distinction between tax evasion, which is legal, and tax fraud, which is not. To make matters harder for international revenue investigators, the Swiss will only co-operate with tax officials if the issue they are pursuing is also a crime in Switzerland. It is a situation that helps the world's richest individuals hide trillions of dollars.

And despite growing international pressure for it to lift the veil of secrecy, powerful conservative forces are massing, determined to stand up to what they argue is hypocritical bullying by the international community.

When earlier this month Brown and Alistair Darling both attacked Swiss secrecy, its bankers were beside themselves with rage. They argue that the UK is at the forefront of aggressive tax evasion through a nexus that connects the City of London with the Channel Islands, the Isle of Man and the Caribbean.

But a senior UK figure working for a Swiss bank said while London bankers are adept at hiding cash from the tax man, Switzerland's role is also crucial: "Swiss and other banks use the same methods in London as they did in the US, including offshore entities in the British Virgin isles et al, indirect telecommunications, credit card accounts linked to the Swiss account, utility bills sent to the bank for payment, even account officers collecting cash from Switzerland."

It is one thing contending with the ire of Britain, France and Germany. But the Swiss have to deal with an increasingly hostile US administration. US officials are infuriated at what they see as obstruction from the Swiss who, they believe, do not have a leg to stand on. President Barack Obama's officials are acutely aware of how leading figures in the Swiss government backed his presidential opponent, John McCain, last year.

The country that helped finance Hitler's rise to power, hid gold looted from Holocaust victims and protected the illicit fortunes of some of the world's most corrupt rulers will not go down without a fight. Right-wing parties have started collecting 100,000 signatures to trigger a referendum to enshrine bank secrecy in Switzerland's constitution.

But the decline in Switzerland's fortunes is largely tied to the collapse of UBS: if the bank was not so weak, the country's financial community believes they would have more chance of resisting international pressure. The anger among UBS bankers towards board members who not only sanctioned huge investment in sub-prime assets at the top of the market, but failed to stop its wealth management arm breaking US law - despite being so advised by its staff - is palpable. "The board were a third-rate Swiss old boys' network," says a senior UBS figure in London. "They are far too distant. They deserve to be shot."

That opinion is shared by the Swiss media and most of the public. Last month, the Zurich headquarters of UBS was attacked by furious protesters, who splattered its imposing whitewashed stone walls with paint. The Swiss media has, unusually, lambasted its financial elite, helping to force UBS bankers to hand back a portion of their windfall.

Bankers are unused to derision. And it shows. Shrunken and nervous, Rohner's last public act as UBS chief executive last Tuesday was to tell viewers on Swiss television talk show Club that the bank would not give an inch on secrecy. "To disclose and divulge bank data: this is a conception of the world that I do not share," Rohner said. The next day, he lost his job.

A UBS spokesman this weekend said that with the appointment of Oswald Grübel - seen as the man who rescued Credit Suisse after it was laid low by its part in the dotcom flotation scandal - as the new chief executive, the bank was now fighting back. "UBS is going through change," he said. "We are addressing and solving problems. The problems led to outflows. That's quite clear: it's not just a flight of clients. Clients are deleveraging.

"But we are paying back debt. We are on the way. We think we will be profitable in 2009. We are rebuilding trust. We have clearly acknowledged fraud. We took responsibility. It's part of our deferred prosecution that we will overhaul our compliance and control framework. Also in our offshore overseas operations, this is something we are working on."

Grübel is seen as UBS's last hope of survival. But those close to the bank say it has suffered such huge shocks that another blow could be fatal. The risk of corporate loan defaults and its exposure to international credit markets during a recession are cited as major risk factors.

Swiss insiders suggest it will offer to pay a proportion of tax on its wealthy clients so long as it can protect their identities. But the future of Switzerland lies in Obama's hands. He has promised a crackdown on tax havens. If he convinces fellow world leaders at the G20 that bank secrecy cannot be tolerated at a time when the world needs every penny to haul itself out of the mire, then Switzerland will be done for. This was not the way the fairytale was meant to end.

The secret history

The secrecy of Swiss banks dates back to the middle ages and was used to hide wealth by many of Europe's dynasties and the Vatican, even though Switzerland had embraced Protestantism.

Secrecy became official Swiss government policy during the First World war and was made law in 1934.

Swiss financiers have faced criticism for destabilising democracy during the last 100 years. In 1923, Adolf Hitler visited Zürich to raise money for his party, and was said to have met bankers at the famous Hotel St Gotthard.

Swiss banks were used by the Nazis to stash looted gold. A UBS security guard blew the whistle on the bank's attempts to destroy records dating back to that time; he was sacked for his trouble. In 1998, an independent panel of experts found Swiss banks were guilty of accepting Nazi deposits, even though they knew those deposits involved theft.

Up to 19 Swiss banks, including Credit Suisse, were used by corrupt former Nigerian ruler Sani Abacha, who looted £3bn from his country. But the Swiss Bankers' Association points out that its report revealed the banks' identities, which is more than British regulators managed in the Abacha case.