The Treasury has struck a deal with the Swiss government to repatriate unpaid British taxes from private bank accounts and end the exploitation of the country's secretive banking system.

Switzerland has agreed to make a one-off deduction from all existing accounts held by people who are liable for British taxes but have not paid them. The tax grab could raise as much as £5bn for the Treasury and will be applied in 2013.

The Swiss are giving Britain 500m Swiss francs (£384m) up front as a gesture of goodwill.

From 2013 onwards, the Swiss government and banks have jointly agreed to apply a new "withholding" tax on behalf of the British government of 48% on investments and 27% on gains where the records show the person is liable for unpaid British taxes, effectively ending the country's reputation as a tax haven.

The deal will mean that the Swiss government and banks will identify accounts held by British taxpayers acting on information from HMRC, withhold the funds and return them to the UK. HMRC will never see the details of the accounts, but if people want to challenge a payment they will be expected to disclose them to UK tax inspectors.

George Osborne said that the days when people could "stash the profits of tax evasion" in Switzerland were over. However, campaigners against tax evasion said that it would mean that people would be offered discounted rates of tax in Switzerland compared with the UK; that the Swiss had retained most of the secrecy in the system which they will operate and that it could undermine a more ambitious EU-wide deal that is still being negotiated.

Richard Murphy, director of Tax Research UK, said: "It's an appalling deal for the UK, an appalling deal for Europe. The one-off tax of 34% is much lower than they would have paid in the UK and in fines for avoiding it. This government is deliberately letting these people off. All those people who have been honest and paid their taxes are now saying 'why did I bother?'

"The Swiss will not pass over the details from the British accounts. The UK will never know who these people are unless they decide to disclose their details and challenge the payments. We have now outsourced British tax justice to the Swiss, who to date have done their utmost to avoid this. We've also given them a competitive advantage over British banks with lower tax rates."

John Christensen, director of Tax Justice, said: "This sets back European-wide attempts to create a proper framework for information exchange and Britain and Germany have done disservice to the rest of the world because this maintains Swiss secrecy. This is a shabby deal."

The Treasury said that the rates of the withholding tax had been set slightly lower than the normal British ones to account for the fact that deductions will take effect sooner than would happen under the British tax system and that the one-off tax rate accounted for the fact that the taxpayer wouldn't have to fund lengthy investigations to recoup the money.

Treasury insiders acknowledged that the negotiations with the Swiss system had been "painstaking" and, at times, "delicate". It follows shortly after a similar deal was struck between the Swiss and the Germans, which is almost identical apart from the upfront payment, which was nearly four times the amount.

The deal will also apply to people who are non-domiciled for tax purposes - they will be approached by the Swiss and given the option of either paying the one-off tax on their whole account unless they can prove that some or all of the money was from elsewhere in the world.

Osborne said: "Tax evasion is wrong at the best of times, but in economic circumstances such as the present ones, it means that hard-pressed taxpayers are forced to pay even more. That is why this coalition government made it a priority to go after those who don't pay their fair share. We will be as tough on the richest who evade tax as on those who cheat on benefits. The days when it was easy to stash the profits of tax evasion in Switzerland are over."

The Swiss Bankers Association welcomed the fact that the deal maintained account holders "financial privacy" and stressed that while the maximum rate would be 34%, the "effective" rate for most clients would be closer to between 20% and 25% of total assets. Despite suggestions that the move could bring in £5bn for the Treasury, the Swiss banks suggested it could also cost them hundreds of millions of pounds if people withdrew savings.