Without a deal, Cyprus' banking system would have collapsed and the country could have become the first to crash out of the European single currency.
Swiftly backed by euro zone finance ministers, the plan will spare the Mediterranean island a financial meltdown by winding down the largely state-owned Popular Bank of Cyprus, also known as Laiki, and shifting deposits below €100,000 to the Bank of Cyprus to create a "good bank". Deposits above €100,000 in both banks, which are not guaranteed under EU law, will be frozen and used to resolve Laiki's debts and recapitalise Bank of Cyprus through a deposit/equity conversion.
The raid on uninsured Laiki depositors is expected to raise €4.2 billion. Laiki will be shuttered, with thousands of job losses.
Banks in Cyprus remain closed and the country is expected to continue some controls on the movement of money when they reopen.
An EU spokesman said no levy or tax would be imposed on deposits in banks.
Global stocks rallied after the announcement of the deal, while the euro and oil rose.