Greek Finance Minister Yanis Varoufakis (left) and German Finance Minister Wolfgang Schaueble at the start of an extraordinary eurozone finance ministers meeting to discuss Athens' plans to reverse austerity measures agreed to as part of its bailout, in Brussels Feb. 20, 2015. Reuters/Yves Herman

Greece and eurozone finance ministers have reached a deal that will extend the country's bailout program for four months, The Associated Press and Reuters reported, citing officials. The move ends weeks of uncertainty and removes immediate fears that Greece would face bankruptcy by the end of the month, risking a possible Greek exit from the 19-member eurozone.

"It's done. For four months," an official told Reuters Friday.

Under the terms of the agreement, Greece is required to submit a letter by Monday to Eurogroup finance ministers "listing all the policy measures it plans to take during the remainder of the bailout period, to ensure they complied with conditions," Reuters reported.

Eurozone officials held an emergency meeting Friday to discuss debt negotiations over Greece’s $270 billion bailout package after Germany surprised the global financial markets Thursday when it rejected the Greek government’s request for a six-month assistance package. Greece and eurozone officials failed to reach an agreement over the country’s debt program Monday, as well as during talks last week after Greece rejected a six-month extension offer from European Union finance ministers.

Greece wanted to renegotiate the terms of its $270 bailout program after the country’s far-left Syriza Party won Greek elections last month. Before winning national elections, the Syriza Party, led by newly elected Prime Minister Alexis Tsipras, staged a revolt against the budget cuts and other austerity measures under the bailout arranged by the European Commission, European Central Bank and International Monetary Fund (known as “the troika”). Greece's previous conservative government had agreed to the terms.

Following the report, the euro traded close to session highs at $1.14 against the U.S. dollar. The euro had been trading 0.62 percent lower against the U.S. dollar at $1.12 earlier Friday morning.

Meanwhile, U.S. stocks rallied following the reports, with the Dow Jones Industrial Average and S&P 500 Index hitting all-time highs. The Dow, which measures the share prices of 30 large industrial companies, gained 140.57 points, or 0.78 percent, to 18,126.34, and the S&P 500 stock index added 11.05 points, or 0.53 percent, to 2,108.48. The Nasdaq Composite rose 27.37 points, or 0.56 percent, to 4,952.07.