Greece and its euro zone creditors reached a deal to extend Greece’s bailout for four months, Eurogroup head Jeroen Dijsselbloem said on Friday.

The euro traded near session highs of about $1.14 against the U.S. dollar and stocks rallied after the announcement. The Dow Jones Industrial Average and S&P 500 closed at fresh records on Friday.

European finance ministers came to the agreement Friday as failure to reach a deal threatened Greece’s solvency. The extension will give Greece time to negotiate a follow-up arrangement with creditors as it attempts to undertake fiscal reforms.

“The Greek authorities have expressed their strong commitment to a broader and deeper structural reform process aimed at durably improving growth and employment prospects, ensuring stability and resilience of the financial sector and enhancing social fairness,” the Eurogroup said in a statement.

Ongoing negotiations had contributed to global uncertainty and increased speculation about a potential Greek departure from the euro zone, or “Grexit.” Greece’s ruling Syriza party previously opposed anti-austerity measures imposed as part of its bailout agreement with the European Union and International Monetary Fund.

The extension is contingent on reforms, which Greek officials and Europe will agree on by the end of April. Greece will present a list of reforms by Monday, Dijsselbloem said. The deal will be ratified when creditors are satisfied with reforms.

A euro zone fund for Greek bank recapitalization will remain available throughout the extension, Dijsselbloem added. The ECB is also prepared to reintroduce the waiver that allows banks to use Greek debt as collateral, effectively easing up on Greek banks, Dow Jones reported.

Dijsselbloem called the agreement “a very positive outcome.”

Greek Finance Minister Yanis Varoufakis said the extension marks a positive step, Reuters reported. Greece will not take unilateral actions that would “burden” the Greek budget, he said.

Greece would work with European partners to hit its primary budget surplus target this year, and the extension allowed Greece to patch up relations with Europe, he added.

Varoufakis also said he could “assure” that Greek ATMs won’t be limited next week, Dow Jones reported.