Stocks ended little changed on Tuesday, paring gains after the Dow topped 13,000 for the first time since May 2008, and as higher oil prices damped prospects for the economy.
Greece's securing a bailout to avoid a disorderly default provided some support to stocks, but investors said the news had mostly been priced in to the market.
Fresh highs in oil prices gave investors a reason to sell. U.S. crude futures rose 2.5 percent to a nine-month high of $105.84 a barrel on Iran supply worries.
Since the start of the year, signs of improvement in the economy and stabilization of Europe's debt crisis have driven the Dow up 6.1 percent, while the S&P has climbed 8.3 percent.
The Dow ended at 12,965 after briefly climbing above the psychologically key 13,000. Wal-Mart was the biggest drag on the Dow, sliding after its quarterly profit came in short of expectations.
The S&P 500 ended within two points of the closing high from April 29.
Despite the upbeat news on Greece we're running into some minor selling pressure, given the extent of the rally we've seen, said Fred Dickson, chief market strategist at D.A. Davidson & Co. in Lake Oswego, Oregon.
In addition, gas prices across country are raising some questions about earnings, he said. Higher gasoline prices hurt corporate profits as consumers cut back on other spending and businesses' expenses rise.
The national price of gasoline climbed to $3.59 a gallon in the latest week, the Energy Information Administration said. Chevron
Euro zone finance ministers agreed on a 130 billion euro ($172 billion) rescue for Greece to avert a chaotic default after forcing Athens to commit to unpopular cuts and private bondholders agreed to take bigger losses.
Even with the bailout, Greece faces a long road to economic recovery. European Union officials said the Greek economy will only return to growth in 2014 after a recession that will shrink output by 17 percent.
It's not the end of the story there, said Bryant Evans, investment adviser and portfolio manager at Cozad Asset Management in Champaign, Illinois.
The Dow Jones industrial average <.DJI> finished up 15.82 points, or 0.12 percent, at 12,965.69. The Standard & Poor's 500 Index <.SPX> was up 0.98 point, or 0.07 percent, at 1,362.21. The Nasdaq Composite Index <.IXIC> was down 3.21 points, or 0.11 percent, at 2,948.57.
Wal-Mart shares fell 3.9 percent to $60.07, erasing most of the stock's gains so far in 2012.
Among the day's rising shares, Home Depot Inc
Kraft Foods Inc
Limiting losses on the Nasdaq, Apple Inc
Volume was about 6.7 billion shares traded on the New York Stock Exchange, NYSE Amex and Nasdaq, slightly below the daily average of 7 billion.
The number of declining stocks was about even with advancers on the NYSE, while on the Nasdaq decliners beat advancers by about 8 to 5.
After the closing bell, Dell Inc
Software company Intuit Inc
(Reporting By Caroline Valetkevitch; Editing by Kenneth Barry)