US Markets

Dow sets first record close for 2015, S&P at high on Greece deal

Closing Bell Exchange: EU reaches deal with Greece
EU Greece deal details
Boston's big bucks guy on Greece
Cashin on Greece: Seen this movie before & nobody dies

U.S. stocks rallied on Friday to close at highs on an eleventh-hour resolution between Greece and its creditors in the euro zone.

The Dow Jones industrial average closed up more than 150 points, its first record close for 2015.

The S&P 500 ended the week at its third record close for the year. The Nasdaq also closed higher, within 50 points of the key 5,000 level.

Five-day index performance

Greece and euro zone finance ministers reached deal on Friday to extend the Greek bailout by four months.

"This obviously is a relief for the markets," said Peter Cardillo, chief market economist at Rockwell Global Capital. "Looks like my 2,125, 2,150 (on the S&P 500) likely to be achieved early next week. (We have) light volume but we're at record highs."

Read MoreDeal reached between Greece, creditors: Reports

"Looks like the agreement ... was already "baked" into the market. Not much of a surprise here," said Lance Roberts, general partner at STA Wealth Management. "The real issue is that this agreement only gets them to the nextbig debt maturity which puts them back at this all over again. A kick the can down the road for now."

The U.S. 10-year Treasury yield rose to trade near 2.13 percent on the Greece news.

"Obviously (we) see safe haven money exit the bond market (and) come flying into stocks," Cardillo said.

Stocks opened in the red on Friday, with the Dow initially falling more than 100 points and only the Nasdaq holding mildly higher.

The Eurogroup of regional finance ministers was expected to make an announcement on Greece's loan extension proposal on Friday. Germany rejected the plan on Thursday and called it a "Trojan horse" with "immense room for interpretation."

Greece faced the risk of default and exit from the euro zone if the country did not obtain enough funding or an extension beyond the Feb. 28 deadline.

In other geopolitical news, the Financial Times reported that NATO forces need to prepare for a major assault by Russia on an eastern European member state.

The euro reached session highs against the U.S. dollar of about $1.14 before paring gains. The U.S. dollar traded lower against major world currencies.

Read MoreNasdaq 5,000: Why this time it's different (really)

"I think this market still has legs ... as long as corporate earnings stay positive," said Doug Cote, chief market strategist at Voya Investment Management.

Deere said it earned $1.12 per share for its latest quarter, well above the 83 cent consensus estimate, with revenue also beating forecasts. However, the farm machinery manufacturer highlighted difficult global market conditions and said it expected a 17-percent drop in equipment sales for 2015.

The outlook cut is "a global macro call," Hogan said. "It's really Brazil. If you think about John Deere and Caterpillar, they're global players."

Barclays downgraded Wal-Mart to "equal weight" from "overweight," saying the retailer is unlikely to see near-term benefits from its just-announced increase in wages that offset the higher expenses.

Newmont Mining earned an adjusted 17 cents per share for its latest quarter, 7 cents above estimates, with its revenue also beating forecasts. Newmont said its "growth projects" are doing particularly well.

The Noodles restaurant chain missed estimates by a penny with adjusted quarterly profit of 13 cents per share, with revenue falling just below estimates as well. It also cut its full-year guidance, as same-restaurant sales growth fails to meet prior forecasts.

In other corporate news, Pacific Investment Management Co. said Paul McCulley is stepping down as chief economist and managing director.

The Markit PMI Manufacturing flash was 54.3, up from 53.9 in January and the highest reading since November but weaker than the 55.9 average for all of 2014. The data also showed production levels rose at their fastest pace in four months.

"That was good but all eyes are on Europe at the moment," said Bill Stone, chief investment strategist at PNC Asset Management.

The CBOE Volatility Index (VIX), widely considered the best gauge of fear in the market, traded near 14.

High-frequency trading accounted for 47.5 percent of February to date's average daily trading volume of approximately 7 billion shares, according to TABB Group. During the peak levels of high-frequency trading in 2009, about 61 percent of 9.8 billion of average daily shares traded, were executed by high-frequency traders.

Major U.S. Indexes

The Dow Jones Industrial Average closed up 154.9 points, or 0.86 percent, at 18,140.70, with Procter & Gamble the greatest of five laggards and Boeing trading at all-time highs (since 1952) to lead blue-chip advancers.

The S&P 500 closed up 12.85 points, or 0.61 percent, at 2,110.30, with health care leading gains across all sectors except energy.

The Nasdaq closed up 31.27 points, or 0.63 percent, at 4,955.97.

Two stocks advanced for every decliner on the New York Stock Exchange, with an exchange volume of 734 million and a composite volume of 3.1 billion in the close.

Read MoreThese stocks are the sweet spot for the market

Crude oil settled down 82 cents to $50.34 a barrel on the New York Mercantile Exchange. Gold futures settled down $2.70 to $1,204.90 an ounce.

CNBC's Peter Schacknow contributed to this report.