Cyprus clinched a last-ditch deal with international lenders to shut down its second largest bank and inflict heavy losses on uninsured depositors, including wealthy Russians, in return for a 10 billion euro ($13 billion) bailout.
The agreement came hours before a deadline to avert a collapse of the banking system in fraught negotiations between President Nicos Anastasiades and heads of the European Union, the European Central Bank and the International Monetary Fund.
Swiftly endorsed by euro zone finance ministers, the plan will spare the east Mediterranean island a financial meltdown by winding down Popular Bank of Cyprus, also known as Laiki, and shifting deposits below 100,000 euros to the Bank of Cyprus to create a "good bank".
Deposits above 100,000 euros in both banks, which are not guaranteed under EU law, will be frozen and used to resolve Laiki's debts and recapitalize Bank of Cyprus through a deposit/equity conversion.
The raid on uninsured Laiki depositors is expected to raise 4.2 billion euros, Eurogroup chairman Jeroen Dijssebloem said.
Laiki will effectively be shuttered, with thousands of job losses. Officials said senior bondholders in Laiki would be wiped out and those in Bank of Cyprus would have to make a contribution.
An EU spokesman said no across-the-board levy or tax would be imposed on deposits in Cypriot banks, although the hit on large account holders in the two biggest banks is likely to be far greater than initially planned. A first attempt at a deal last week collapsed when the Cypriot parliament rejected a proposed levy on all deposits.
German Finance Minister Wolfgang Schaeuble said lawmakers would not need to vote on the new scheme, since they had already enacted a law setting procedures for bank resolution.
"It can't be done without a bail-in in both banks... This is bitter for Cyprus but we now have the result that the (German) government always stood up for," Schaeuble told reporters, saying he was sure the German parliament would approve.
A senior source in the talks said Anastasiades threatened to resign at one stage on Sunday if he was pushed too far. He left EU headquarters without making any comment.
Conservative leader Anastasiades, barely a month in office and wrestling with Cyprus' worst crisis since a 1974 invasion by Turkish forces split the island in two, was forced to back down on his efforts to shield big account holders.
Diplomats said the president had fought hard to preserve the country's business model as an offshore financial centre drawing huge sums from wealthy Russians and Britons but had lost.
The EU and IMF required that Cyprus raise 5.8 billion euros from its banking sector towards its own financial rescue in return for 10 billion euros in international loans. The head of the EU rescue fund said Cyprus should receive the first emergency funds in May.
IMF chief Christine Lagarde said the agreement was "a comprehensive and credible plan" that addresses the core problem of the banking system.
"This agreement provides the basis for restoring trust in the banking system, which is key to supporting growth," she said in a statement.
With banks closed for the last week, the Central Bank of Cyprus imposed a 100-euros per day limit on withdrawals from cash machines at the two biggest banks to avert a run.
French Finance Minister Pierre Moscovici rejected charges that the EU had brought Cypriots to their knees, saying it was the island's offshore business model that had failed.
"To all those who say that we are strangling an entire people ... Cyprus is a casino economy that was on the brink of bankruptcy," he said.
The euro gained against the dollar on the news in early Asian trading.
Analysts had said failure to clinch a deal could cause a financial market selloff, but some said the island's small size - it accounts for just 0.2 percent of the euro zone's economic output - meant contagion would be limited.
The abandoned plan for a levy on bank deposits had unsettled investors since it represented an unprecedented step in Europe's handling of a debt crisis that has spread from Greece, to Ireland, Portugal, Spain and Italy.
In the Cypriot capital, Nicosia, the mood on Sunday was anxious.
"I haven't felt so uncertain about the future since I was 13 and Cyprus was invaded," said Dora Giorgali, 53, a nursery teacher who lost her job two years ago when the school she worked at closed down.
"I have two children studying abroad and I tell them not to return to Cyprus. Imagine a mother saying that," she said in a central Nicosia square.
Cyprus's banking sector, with assets eight times the size of the economy, has been crippled by exposure to Greece, where private bondholders suffered a 75 percent "haircut" last year.
Without a deal by the end of Monday, the ECB said it would have cut off emergency funds to the banks, spelling certain collapse and potentially pushing the country out of the euro.
Under the bailout agreement, Laiki's ECB funds will pass to Bank of Cyprus and the central bank will "provide liquidity to BoC in line with applicable rules".
Anticipating a run when banks reopen on Tuesday, parliament has given the government powers to impose capital controls.
About 200 bank employees protested outside the presidential palace on Sunday chanting "troika out of Cyprus" and "Cyprus will not become a protectorate".
In a stunning vote on Tuesday, the 56-seat parliament rejected a levy on depositors, big and small. Finance Minister Michael Sarris then spent three fruitless days in Moscow trying to win help from Russia, whose citizens and companies have billions of euros at stake in Cypriot banks.
On Friday, lawmakers voted to nationalize pension funds and split failing lenders into good and bad banks - the measure to be applied to Laiki. The plan to tap pension funds was shelved due to German opposition, a Cypriot official said.
The tottering banks held 68 billion euros in deposits, including 38 billion in accounts of more than 100,000 euros - enormous sums for an island of 1.1 million people which could never sustain such a big financial system on its own.