Cyprus secured a package of rescue loans in tense, last-ditch negotiations early Monday, two EU diplomats said, saving the country from a banking system collapse and bankruptcy.

The cash-strapped island nation needs a 10 billion euro bailout ($13.3 billion Cdn) to recapitalize its ailing banks and keep the government afloat. The European Central Bank had threatened to cut crucial emergency assistance to the country's banks by Tuesday without an agreement.

The finance ministers of the 17-nation eurozone accepted the plan reached in 10 hours of negotiations, the diplomats said. They spoke on condition of anonymity pending the official announcement.

Under the plan, Cyprus' second-largest bank, Laiki, will be restructured and holders of bank deposits of more than 100,000 euros ($132,880) will have to take losses.

The diplomats also did not elaborate on how much large deposit holders would lose. Making them take a hit is expected to net several billion euros, reducing the amount of rescue loans the country needs.

10 hours of negotiations

Without a deal by Monday night, the tiny Mediterranean island nation of about 1 million would have faced the prospect of bankruptcy, which could force it to abandon the euro currency and spur turmoil in the eurozone of 300 million people.

To secure a rescue loan package, Nicosia had to find ways to raise 5.8 billion euros ($7.71 billion) so it could qualify for the 10 billion euro bailout package. The bulk of that money is now being raised by forcing losses on large deposit holders as well as bond holders in Laiki bank, which will be split into a bad bank of toxic assets and a remaining viable core business.

But Cyprus resisted pressure by creditors to also unwind the country's largest lender, Bank of Cyprus, one of the diplomats said.

In Cyprus, Parliament President Yiannakis Omirou confirmed that a preliminary agreement had been reached after about 10 hours of negotiations in Brussels. He couldn't provide details but stressed the agreement "doesn't involve the resolution of the Bank of Cyprus."

The European Central Bank had threatened to stop providing emergency funding to Cyprus' banks as of Tuesday if there were no agreement on how to raise the 5.8 billion euros ($7.7 billion)

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 among Cypriots because it also targeted small savers. It failed to win a single vote in the Cypriot Parliament.

Daily withdrawal limit of 100 euros

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

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.

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

Several national parliaments in eurozone countries such as Germany then must also approve the bailout deal, which might take another few weeks.