Stock market hits new high after Greece gets loan extensionAP Photo XEH101

Two of the three major U.S. stock indexes hit new record highs Friday. The Nasdaq is closing in on its peak as well.

A deal giving Greece more time to repay its debts swung the U.S. stock market higher Friday and drove the stock market to a record high.

While expected, the deal between the struggling country and its European creditors left investors relieved. Any failure to reach an accord could have sent tremors through markets at a time when Europe is trying to revive its regional economy.

“It’s good this didn’t go down to the wire to get resolved,” said Paul Christopher, head of international strategy at Wells Fargo.

Stocks started off the day solidly lower. The Dow Jones industrial average fell as much as 107. But as rumors and news came out that Greece and its creditors were close to a deal, the market climbed ever-so-steadily higher. The euro also gained against the dollar.

The Dow finished up 154.67, or 0.9 percent, to 18,140.44. The S&P 500 index climbed 12.85, or 0.6 percent, to 2,110.30 and the Nasdaq composite rose 31.27, or 0.6 percent, to 4,955.97. The Dow closed at a record high, surpassing its record close on Dec. 26. The S&P 500 also closed at record high.

The Nasdaq, which has yet to reclaim its record high from the dot-com era, in now within 93 points of that March 2000 peak.

In Brussels, the deal reached between the European Union and Greece’s recently elected government would extend the country’s repayment plan by four months. That is shorter than the six months originally requested by Greece.

In return, Greece has committed to not pursue any “unilateral” measures that might affect the country’s budget targets. Greece has committed to provide a list of reforms based on its current bailout program for assessment by Monday.

The deal is a shift from only a day ago, where it seemed like Greece and its creditors were still struggling to reach a basic agreement for the Mediterranean country. Without the agreement, Greece would have only about a week left before it would default on its obligations and cause it to drop the euro currency.

Greece’s economy is small, but the potential disruption Greece could have to the global financial system potentially could be huge. In a worst-case scenario, Greece abandoning the euro could embolden political parties in other debt-ridden countries to seek to leave the euro as well.

“A Greek exit is not good for anyone, including the Greeks,” said Christopher of Wells Fargo. “If Greece leaves, everyone else could leave and you’re left with nothing.”