* Swiss banks to pay 2 bln Swiss francs up front
* Existing funds to be taxed at between 19-34 pct
* Deal may set precedent for other countries (Adds comment from British tax office)
ZURICH/BERLIN, Aug 10 (Reuters) - Switzerland and Germany have agreed to tax money stashed by German citizens in secret accounts, in a deal that will net Berlin billions of francs and will force the Swiss banking sector to clean up its act.
Strict secrecy has helped Switzerland build up a $2 trillion offshore financial sector, but the country has faced an international campaign in recent years against tax evasion as cash-strapped governments seek to boost revenues.
Citizens of neighbouring Germany -- keen to claw back funds as the worsening euro zone debt crisis expands its role as the region's main paymaster -- have an estimated 150 billion Swiss francs ($203 billion) hidden in secret accounts.
In a deal that could set a model for agreements between Switzerland and other countries, existing funds will be taxed at a rate between 19 and 34 percent, based on how long the money has been stashed away and the rate of capital gains.
Future investment income and capital gains will be taxed at a rate of 26.375 percent, in line with the current flat-rate withholding tax in Germany.
"It creates legal certainty and will strengthen the competitiveness and reputation of the Swiss financial place in the long term," Finance Minister Eveline Widmer-Schlumpf said in a statement on Wednesday.
Switzerland's two biggest banks -- UBS and Credit Suisse -- welcomed the deal, but Thomas Eigenthaler, head of the German tax trade union, slammed the deal.
"The retroactive tax actually presents a discount (to taxes in Germany) ... and is a slap in the face of tax payers who were honest and always paid the full rate, and it will also be a big disappointment for those who actually denounced themselves as evaders and had to pay a higher rate," Eigenthaler told Reuters.
Switzerland has a similar pact pending with Britain.
"We hope to conclude these as soon as possible," a spokesman for Britain's tax authority said. "Any further details will be announced in due course.
For a Q &A on what is at stake, click on
For a factbox on main points of the deal, click on
BANK SECRECY PRESERVED
The deal -- which takes effect in 2013-- comes after a diplomatic spat between the two countries when former German finance minister Peer Steinbrueck said the Swiss were like Indians running from the cavalry due to the country's stance over tax evasion, prompting a Swiss politician to compare him to a Nazi.
Julius Baer, the country's largest dedicated wealth manger, earlier this year paid a fine to settle with the German tax man, termed the deal a "pragmatic solution". .
German authorities have also raided Credit Suisse's offices in the German city of Duesseldorf, and on Wednesday said they were intensifying their tax evasion probe. Credit Suisse declined to comment.
By introducing a withholding tax on income at source, the deal allows Switzerland to preserve most client confidentiality and head off the automatic exchange of information, which the European Union has been trying to deepen in the bloc.
But Switzerland has agreed to cooperate more readily in the hunt for tax cheats in exchange for Germany's agreement not to buy any more stolen bank data, an issue which had soured ties. Germany also agreed not to take legal action against the employees of Swiss banks.
German officials will be allowed to put in 750-999 requests with their Swiss counterparts in a two-year period, if they have good grounds to suspect cases of tax dodging, but will not be able to pursue any large-scale "fishing expeditions".
To ensure Germans step forward and settle their bills with the tax man, Swiss banks will have to pay 2 billion francs up front, much less than some figures that had been circulated which were seen as too much for the big banks to bear.
UBS and Credit Suisse will probably fork out the bulk of the payment, with the remainder coming from smaller players. The aim is for the banks to be credited if their clients step forward.
"This deal gives them good opportunities to find a solution for the past and remain tax compliant in the future," Claude-Alain Margelisch, Chief Executive Officer of the Swiss Bankers' Association (SBA), told Reuters.
The SBA estimates the deal hands Swiss banks a compliance bill in the mid-three-digit millions of francs.
Swiss banks have also come into the crosshairs of U.S. authorities. In 2009, the Swiss government cut a deal with Washington to hand over the details of 4,450 UBS accounts in return for the dropping of a damaging lawsuit against the bank.
Similarly to Switzerland, the tiny principality of Liechtenstein has also faced battles over tax cheats, and has signed an agreement with Britain to regularise untaxed assets there.
In an interview on Wednesday with the TagesAnzeiger daily, Liechtenstein's head of government Klaus Tschuetscher said about 1,500 Britons had stepped forward to declare their assets to British tax authorities. (Additional reporting by Martin de Sa Pinto in Zurich, Edward Taylor and Matthias Inverardi in Germany, Sven Egenter in London; Editing by Susan Fenton)