Dow
The Dow Jones Industrial Average soared more than 100 points Friday while the S&P 500 Index hit an all-time record high following reports Greece and eurozone finance ministers agreed on a draft deal that could extend the country's bailout program. Reuters/Brendan McDermid

U.S. stocks gained in afternoon trading Friday, reversing earlier losses, with the S&P 500 Index hitting an all-time high following reports Greece and eurozone finance ministers agreed on a draft deal that could extend the country's bailout program. The blue-chip Dow Jones Industrial Average also rallied Friday, climbing above the psychologically important 18,000 threshold to trade above its previous record close of 18,053.71 set in December.

UPDATE: 4 p.m. EST

U.S. stocks closed higher Friday with the S&P 500 Index and the Dow Jones Industrial Average closing at record highs. The Dow Jones Industrial Average gained 154.67 points, or 0.86 percent, to close at a record high of 18,140.44. The S&P 500 added 12.85 points, or 0.61 percent, t0 end at 2,110.30. The Nasdaq Composite rose 31.27 points, or 0.63 percent, to finish at 4,955.97. The Dow hit an intraday high of 18,144.29 Friday, while the S&P 500 hit an intraday record of 2,110.61 in afternoon trading.

UPDATE: 3 p.m. EST

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 S&P 500 stock index hit an all-time intraday high of 2,107.14 in afternoon trading Friday, breaking its previous record of 2,101.30 set on Tuesday. The S&P 500 added 7.87 points, or 0.38 percent, to trade at 2,105.42 in afternoon trading.

Meanwhile, the Dow Jones Industrial Average, which measures the share prices of 30 large industrial companies, gained 136.48 points, or 0.76 percent, to 18,123.90, putting the blue-chip index on track for its first record close of 2015. The Dow broke its previous intraday record of 18,103.45 set on Dec. 26.

The tech-heavy Nasdaq Composite continued to hover near all-time highs, adding 22.20 points, or 0.45 percent, to 4,946.53.

All three major U.S. indices gained Friday following reports Greece and eurozone finance ministers agreed on a deal, ending weeks of uncertainty and removing immediate fears that Greece would face bankruptcy by the end of the month, risking a possible Greek exit from the 19-member eurozone.

The emergency meeting comes as time is running out on Greece's current bailout program, which expires Feb. 28.

"Even if a deal is cobbled together at the latest emergency meeting, it will need to be ratified by several parliaments and possibly even subjected to a Greek referendum. In the meantime, the European Central Bank might pull the plug on the banking system," Roger Bootle and Jonathan Loynes, economists at Capital Economics, said in a research note Friday.

The European Central Bank approved a 68 billion euro ($77 billion) two-week extension on emergency liquidity for Greek banks Wednesday. Failure to reach an agreement would potentially lead to Greece leaving the 19-member eurozone.