Greece is to receive loans worth more than EUR130billion (US$170 billion).
In return, Greece will undertake to reduce its debts to 120.5% of its GDP by 2020 and accept an 'enhanced and permanent' presence of EU monitors to oversee economic management.
A first rescue package worth EUR110 billion in 2010 was not enough to avert Greece's deepening crisis.
Greece needs the funds to avoid bankruptcy on March 20, when maturing loans must be repaid.
After five straight years of recession, Greece's debt currently amounts to more than 160% of its Gross Domestic Product.
Eurozone leaders and the IMF said in October that Greek debt should be reduced to a more sustainable level of 120% of GDP by 2020.
The euro immediately rose on reports of the deal, which was announced early on Tuesday by Jean-Claude Juncker, prime minister of Luxembourg and chairman of the eurozone finance ministers group, after 13 hours of talks.
Mr Juncker said the 'far-reaching' deal would lead to 'a very significant debt reduction for Greece' and ensure its future within the eurozone.
He said 'the eurogroup is fully aware of the significant efforts already made by the Greek citizens'.
But he added that 'further major and joint efforts by all parts of the Greek society are needed to return the economy to a sustainable growth path.'
The head of the IMF, Christine Lagarde, who also took part in the negotiations, said the deal 'should give enough space for Greece to restore its competitiveness'.
Speaking after the deal was reached, Greek Prime Minister Lucas Papademos said he was 'very happy' with the outcome.
Within the next two months, Greece will also have to pass legislation giving priority to debt repayments over the funding of government services.
Athens will also have to set up a special account, managed separately from its main budget, that will at all times have to contain enough money to service its debts for the coming three months.
The Greek parliament is expected to vote on the bailout on Wednesday.