The deal, described by the country's politicians as "painful", was agreed with euro finance ministers in Brussels just in time. The European Central Bank had threatened to cut off crucial emergency assistance to the Cyprus's embattled banks after Monday if no agreement was reached.

Without that funding, Cyprus's banks would have collapsed, dragging the country's economy down with them and threatening the small Mediterranean island's membership of the 17-strong group of European Union countries that use the euro - all of which would have sent the EU's markets spinning.

"It's not that we won a battle, but we really have avoided a disastrous exit from the eurozone," Finance Minister Michalis Sarris said in Brussels.

Markets in Europe reacted positively, opening sharply higher, and the euro was back near $1.30.

The mood in Nicosia was more somber, however.

"This decision is painful for the Cypriot people. This decision was a defeat of solidarity, of social cohesion, which are fundamental freedoms, fundamental principles of the European Union," Parliament President Yiannakis Omirou told AP.

"So as soon as possible we have to prepare our economy to go out from the mechanism and the troika," he said, referring to the bailout agreement and the three-member delegation from the European Commission, International Monetary Fund and ECB who oversee implementation of bailout measures.

Banks in Cyrpus have been closed for more than a week in Cyprus while politicians wrangled on how to raise 5.8 billion euros ($7.5 billion) to qualify for the rescue. An alternative was needed after the country's lawmakers resoundingly defeated the initial plan which would have seized up to 10 percent of funds in people's accounts in all banks.

While cash has been available through ATMs, many machines have quickly run out. Daily withdrawal limits of 100 euros were imposed on ATMs of country's two troubled lenders, Laiki and Bank of Cyprus, on Sunday. All banks are scheduled to reopen Tuesday.

Under the new plan, the bulk of the funds will be raised by forcing losses on wealthy savers in two of the country's banks, with the remainder coming from tax increases and privatizations.

Laiki, the country's second-largest bank, will be restructured, with all bond-holders and people with more than 100,000 euros in their accounts facing significant losses. The bank will be dissolved immediately into a bad bank containing its uninsured deposits and toxic assets, with the guaranteed deposits being transferred to the nation's biggest lender, Bank of Cyprus.

Deposits at Bank of Cyprus above the 100,000 euro insured level will be frozen until it becomes clear whether or to what extent they will also be forced to take losses. The money from those deposits will eventually be converted into bank shares. German Finance Minister Wolfgang Schaeuble said he expected a bit more than 50 percent of savings at Bank of Cyprus will be involved in the swap.

It is not yet clear how severe the losses would be to Laiki's large bank deposit holders, but the euro finance ministers noted the restructure expected to yield 4.2 billion euros overall. Analysts have estimated investors might lose up to 40 percent of their money.

The plan agreed Monday does not need extra approval from Cyprus's parliament because the losses are part of a restructuring of the island's banks - which would come under legislation passed last week - and not a tax.

To further secure Cyprus's economy, the size of the country's banking sector - worth up to eight times the country's gross domestic product of about 18 billion euros- must also be drastically reduced , said Jeroen Dijsselbloem, who chairs the meetings of the eurozone's finance ministers.

The international creditors also said the country's business model of attracting foreign investors, including many Russians, with low taxes and lax financial regulation had backfired and needed to be reformed. The country would also have to cut its budget, implement structural reforms and privatize state assets.

Russia's prime minister on Monday slammed the deal, saying the agreement was tantamount to theft: "In my opinion, the stealing of what has been stolen continues there."

Moscow has been worried about the crisis in Cyprus with Russian citizens holding as much as 20 billion euros ($26 billion) in Cypriot banks.

"Despite all the assurances that we're receiving from the European Commission we fear that this (decision) could affect the stability of the euro, the stability of the eurozone and would send shockwaves to deteriorate the situation on the whole," he said.

Germany's Schaeuble, however, rejected the idea that the deal was a defeat for European solidarity.

"Cyprus is in a serious crisis, it needs help; Cyprus is getting that help," he said. "Europe is showing solidarity, Europe continues to show solidarity, but aid only makes sense and is only responsible when it overcomes the causes that lead to such crises."

He insisted that the deal was "the best possible way for Cyprus out of this crisis ... but it still is not a comfortable way."

Several national parliaments in eurozone countries such as Germany must approve the deal, which might take another few weeks. EU officials said they expect the whole program to be approved by mid-April.

Cyprus has been shut out of international markets for almost two years. It first applied for a bailout to recapitalize its ailing lenders and keep state finances afloat last June, but negotiations stalled. The uncertainty around the tiny nation of about 800,000 had shaken the entire eurozone of 300 million people, even though Cyprus only makes up less than 0.2 percent of the eurozone's economy.

The new measures are likely to deepen the recession in Cyprus.

"Nobody doubts that the Eurogroup decision and the agreement for our country's loans from the troika is a very painful agreement," said Nicholas Papadopoulos, head of Parliament's finance committee. "The consequences for the Cypriot economy and the daily lives of all the citizens will be seen in practice."

____

Geir Moulson in Berlin, Don Melvin and Juergen Baetz in Brussels, Pan Pylas in London and Nataliya Vasilyeva in Moscow contributed to this report.