Updated

Cyprus secured a 10 billion euro ($13 billion) package of rescue loans in tense, last-ditch negotiations early Monday, saving the country from a banking system collapse and bankruptcy that could have destabilized the entire euro area.

"We've put an end to the uncertainty that has affected Cyprus and the euro area over the past week," said Jeroen Dijsselbloem, who chairs the meetings of the 17-nation eurozone's finance ministers.

In return for the bailout, Cyprus must drastically shrink its outsized banking sector, cut its budget, implement structural reforms and privatize state assets, he said. The country's second-largest bank will be shut down immediately, with all bond holders and people with more than 100,000 euros in their bank accounts there facing significant losses. The measures are likely to deepen the recession in Cyprus and lead to more job losses.

The cash-strapped Mediterranean island nation has been shut out of international markets for almost two years. It first applied for a bailout to recapitalize its ailing lenders and keep the government afloat last June, but the political negotiations stalled. After a botched agreement last week, the European Central Bank moved forcefully to focus leaders' minds, threatening to cut off crucial emergency assistance to the country's banks by Tuesday if no agreement was reached.

"It's not that we won a battle, but we really have avoided a disastrous exit from the eurozone," said Cyprus' Finance Minister Michalis Sarris. "A long period of uncertainty and insecurity surrounding the Cyprus economy has ended."

The eurozone finance ministers accepted the plan, reached after more than 10 hours of negotiations in Brussels between Cypriot officials and the so-called troika of creditors — the International Monetary Fund, the European Commission and the ECB.

"We believe that this will form a lasting, durable and fully financed solution," said IMF chief Christine Lagarde.

Without a bailout deal by Monday night, the tiny nation of about 800,000 would have faced the prospect of bankruptcy, which could have forced it to become the first country to abandon the euro currency. That would have roiled markets and spurred turmoil across the entire eurozone of 300 million people, analysts said, even though Cyprus only makes up less than 0.2 percent of the eurozone's 10 trillion euro economy.

After the eurozone's finance ministers' approval, several national parliaments in eurozone countries such as Germany must also approve the bailout deal, which might take another few weeks. EU officials said they expect the whole program to be approved by mid-April.

Under the plan, Cyprus' second-largest bank, Laiki, will be restructured and holders of bank deposits of more than 100,000 euros there will have to take losses, Dijsselbloem said, adding that it was not yet clear how severe the losses would be.

"This will have to be worked out in the coming weeks," he added, noting that it is expected to yield 4.2 billion euros overall. Analysts have estimated investors might lose up to 40 percent of their money.

Savers' deposits with all Cypriot banks of up to 100,000 euros will be guaranteed by the state in accordance with the EU's deposit insurance guarantee, Dijsselbloem said. Laiki 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.

Large deposits with Bank of Cyprus above the insured level will be frozen until it becomes clear whether or to what extent they will also be forced to take losses, the Eurogroup of finance ministers said in a statement.

Dijsselbloem defended the creditors' approach of making deposit holders take heavy losses, saying the measures "will be concentrated where the problems are, in the large banks."

The international creditors, led by the IMF, were seeking a fundamental restructuring of the country's outsized financial system, which is worth up to eight times the Cypriot gross domestic product of about 18 billion euros. They said the country's business model of attracting foreign investors, among them many Russians, with low taxes and lax financial regulation had backfired and needed to be upended.

The drastic shrinking of the financial sector, the wiping out of wealth through the losses on deposits, the loss of confidence with the recent turmoil and the upcoming austerity measures all mean that Cyprus is facing tough times.

"The near future will be very difficult for the country and its people," acknowledged the EU Commission's top economic official, Olli Rehn. "But (the measures) will be necessary for the Cypriot people to rebuild their economy on a new basis."

Cypriot banks have been closed this past week while officials worked on a rescue plan, and they are not due to reopen until Tuesday. Cash has been available through ATMs, but long lines formed and many machines have quickly run out of cash.

Amid fears of a banking collapse, Cyprus' central bank on Sunday imposed a daily withdrawal limit of 100 euros ($130) from ATMs of the country's two largest banks to prevent a bank run by depositors worried about their savings.

The Cypriot government also approved a set of laws over the past week to introduce capital controls, in order to avoid a huge depositor flight once banks reopen.

To secure the rescue loan package, the Cypriot government had to find ways to raise several billion euros on its own. The bulk of that money is now being raised by forcing losses on large deposit holders, with the remainder coming from tax increases and privatizations.

The creditors had insisted that Cyprus couldn't receive more loans because that would make its debt burden unsustainably high. The IMF's Lagarde said Cyprus would now reach a debt level of about 100 percent of GDP by 2020.

A plan agreed to in marathon negotiations earlier this month called for a one-time levy on all bank depositors in Cypriot banks. But the proposal ignited fierce anger because it also targeted small savers. It failed to win a single vote in the Cypriot Parliament.

Cyprus' bid to secure more financial aid from its long-time ally, Russia, then failed, forcing it to turn again to its European partners. Russia was expected, however, to extend a 2.5 billion euro emergency loan granted last year, also lowering the interest rate due and extending then repayment schedule.

___

Associated Press writers Elena Becatoros and Menelaos Hadjicostis in Nicosia, Cyprus, contributed to this story.

______

Juergen Baetz can be reached at http://www.twitter.com/jbaetz

Don Melvin can be reached at https://twitter.com/Don_Melvin