Euro zone finance ministers approved a bailout agreement for Cyprus early Monday local time, pulling the Mediterranean island country back from the brink of financial ruin.

"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 euro zone's finance ministers.

To access bailout dollars, Cyprus must cut its budget, privatize assets and shrink its bloated banking sector.

Additionally, Laiki, Cyprus’s second-largest bank, will be restructured and holders of bank deposits of more than 100,000 euros will be required to take losses, Dijsselbloem said.

While it is not clear yet how much large deposit holders stand to lose, the move is expected to generate 4.2 billion euros, Dijsselbloem said.

"We believe that this will form a lasting, durable and fully financed solution," International Monetary Fund Christine Lagarde said of the deal.

Large deposits with Bank of Cyprus above the insured level will be frozen until the extent of losses is known, Eurogroup, the group of euro zone finance ministers, said in a statement.

The agreement was reached in an eleventh-hour attempt to save Cyprus’s ailing banks from collapse, which would have dragged down the government and forced it to give up the euro.

European Central Bank had threatened to stop providing funding to Cyprus banks after Monday if a plan to raise the 5.8 billion euros required to obtain a 10 billion euro rescue loan package was not in place.

The loss of the currency would pose a huge threat to the currency’s stability, currently used by more than 200 million people in 17 EU nations.

An earlier plan, agreed to last week, which called for a one-time levy of all of the country’s bank accounts, was scrapped after it failed to get a single vote in the Cypriot Parliament and sparked fierce opposition from citizens.

The idea resurfaced after an attempt to secure financial aid from Russia failed.

On Friday, Cyprus took steps towards securing a bailout plan, after legislation was approved to restructure the country’s banks, limit emergency financial transactions and create a “solidarity fund” that would act as a tool for raising funds from investments and contributions.

Fearing a potential collapse of its banking system, Cyprus imposed a daily withdrawal limit of 100 euros from the ATMs of two of its largest banks.

The limit is to prevent account holders, worried about the future of their savings, from withdrawing all of their money.

The country’s banks have been shut down for the past week, and will not reopen until Tuesday. Citizens have been able to get cash through ATMs, but many have already run out.

Cyprus needs more than 10 billion euros to avoid bankruptcy or the collapse of its banking system. But fear that additional loans will boost the country’s debt level to an unsustainable level means the country must raise the extra money on its own.

As protesters demonstrated in the streets of Cyprus’s capital, Nicosia, news agencies reported that a homemade bomb had exploded inside a Bank of Cyprus branch. Firefighters were able to quickly extinguish the flames, but the explosion caused some damage.

With files from The Associated Press