European leaders reached an agreement with Cyprus early on Monday morning that closes down the island's second-largest bank and inflicts huge losses on wealthy savers.

Those with deposits of less than €100,000 (£85,000) will be spared, but those with more than €100,000 – many of them Russian – will lose billions of euros under draconian terms aimed at preventing the Mediterranean tax haven becoming the first country forced out of the single currency.

The deal is expected to wreak lasting damage on the Cypriot economy, which has grown reliant on offshore banking and Russian money. Analysts said Cyprus could see its economy contract by 10% or more in the years ahead.

European shares lost early gains, as initial enthusiasm over the bailout deal faded. The FTSE 100 was up just 3 points at 6396 and the German DAX was 0.2% higher. After a brief rally, Italy's FTSE MIB moved sharply into negative territory and was down 2.4% on Monday afternoon. In the US, the Dow dropped 0.25% to 14,476. The euro dropped 1% against the dollar, meaning €1 is worth $1.2874.

A Paris-based trader said: "The loss of confidence in the European banking system stemming from the Cypriot crisis will not only weigh on the banks but also on the economy of the region."

The final deal came close to what the IMF chief, Christine Lagarde, had demanded a week ago but which was rebuffed by the Cypriot president, Nicos Anastasiades.

Laiki, or Cyprus Popular Bank, is to be closed. Its €4.2bn in deposits over €100,000 will be placed in a "bad bank" and could be wiped out entirely. Those with smaller deposits will see their accounts transferred to Bank of Cyprus.

The Cypriot government reportedly fought hard for Bank of Cyprus to be spared, but the island's biggest bank will face huge restructuring. No bailout money will be used to recapitalise it; instead shareholders and bondholders will be hit. It is thought depositors with more than €100,000 at the bank will also be involved in the recapitalisation, and are expected to face losses of around 30%.

Getting the bank up to healthy EU-mandated capital levels will be made harder by the fact that Bank of Cyprus will inherit a €9bn debt Laiki had with the European Central Bank (ECB).

The bailout deal does not need approval from the Cypriot parliament because it has been achieved by restructuring the country's two largest banks, rather than levying a new tax on citizens.

Negotiations got under way on Sunday amid a hardening of stance by the IMF and Germany, which insisted that depositors must take the hit for bailing out the eurozone's latest crisis economy.

Reports suggest that Anastasiades threatened to resign amid demands for a deep restructuring of Cyprus's banking system, but he remained in his post on Monday morning: "I'm happy because we shall have a programme and it's in the best interests of the Cyprus people and the European Union," he said, on leaving the building in Brussels where talks were held.

The ECB had threatened to cut off funds propping up Cypriot banks on Monday, which would have precipitated the island's exit from the euro if the emergency meeting had not reached an agreement.

Wolfgang Schäuble, Germany's finance minister, said the deal agreed in Brussels overnight is "much better" from a German point of view than the original plan.

He said the goal was to shrink the Cypriot banking sector to the European average of three-times national output, rather than its current size of seven times.

Cyprus had hoped to secure a rescue package from Russia, but the government was forced into fresh negotiations with its troika of lenders – the EU, the IMF and the ECB – after the Cypriot finance minister, Michalis Sarris, returned empty-handed from two days of talks in Moscow last week.

The new bailout deal will hit foreign investors, particularly Russians, hard. Russian nationals are estimated to hold more than €20bn of the €68bn deposited in Cypriot banks.

Russia's prime minister, Dmitry Medvedev, said on Monday: "They are continuing to steal what has already been stolen," using a phrase Vladimir Lenin used to answer the allegation that the Bolsheviks were thieves.

Russian officials have repeatedly compared the Cypriot bank levy to Soviet-era expropriation.

There were signs of panic over the weekend as a €100 limit was imposed on ATM withdrawals in Cyprus. Officials said they believed the country would now need strict controls on money transfers in and out of the economy, cutting off its citizens and companies from much of the rest of the eurozone's financial system. Europe's economics commissioner, Olli Rehn, said: "The near future will be very difficult for the country and its people." The EC said these controls will, however, only be enacted "exceptionally and temporarily" as requested by the Cypriot authorities.

In Cyprus the mood is grim. Cypriots realise that their economy will take a huge hit and there are worries of long-term unemployment, as big foreign investors are expected to seek ways to flee from the country. Anger remains directed at the EU, and Germany in particular.

Alexandra Salmani, 32, moved to Cyprus eight months ago to escape the financial crisis in Greece. She said: "We came here to find a better life, and it's exactly the same thing as in Greece. Everywhere I go there's crisis – I'm telling all my friends that I'll go to Germany next. Someone has to learn to say no to Merkel. They saw a rich country, decided to take their money, and destroy them. They are not human."