The Dow and S&P ended flat on Friday, giving back earlier gains after the sinking of a South Korean naval ship, while tech shares' weakness kept the Nasdaq in slightly negative territory.

Stocks initially rose after European Union leaders said they had agreed on a standby aid package for Greece, and after better-than-expected March consumer sentiment data.

The Nasdaq felt the weight of Oracle Corp , which fell from a nine-year high a day after reporting quarterly results that beat expectations. The stock slid 1.3 percent to $25.69, while software bellwether Microsoft dropped 1.2 percent to $29.66.

News of the ship sinking hit sentiment, analysts said, although some analysts suggested that the incident was an excuse for investors to sell stocks in what is increasingly viewed as an overvalued market.

Depending on what happened, this could raise global tensions, which will unnerve investors, said Charles Lieberman, chief investment officer of Advisors Capital Management in Paramus, New Jersey.

Lieberman noted that South Korea had played down the suggestion of North Korea's involvement, but said that investors are going to remain cautious until they know what happened for sure.

The Dow Jones industrial average <.DJI> rose 9.15 points, or 0.08 percent, to end at 10,850.36. The Standard & Poor's 500 Index <.SPX> inched up just 0.86 point, or 0.07 percent, to 1,166.59. But the Nasdaq Composite Index <.IXIC> slipped2.28 points, or 0.10 percent, to close at 2,395.13.

Euro-zone leaders unveiled a deal late Thursday in which Athens would receive coordinated bilateral loans from other euro-zone countries and the International Monetary Fund if it faced severe difficulties.

The euro-zone agreement relieved uncertainty about the European Union dealing with the problem, which has weighed on equities in recent weeks.

Earlier on Friday, the Commerce Department said gross domestic product expanded at an annual rate of 5.6 percent in the fourth quarter, instead of 5.9 percent, as it previously estimated and as analysts had been expecting.

Separately, the Thomson Reuters/University of Michigan's Surveys of Consumers consumer sentiment index came in at a final March reading of 73.6, above expectations, but unchanged from February.

Chevron , up 0.9 percent at $74.43, supported the Dow industrials.

Apple Inc rose 1.9 percent to $230.90 and limited the Nasdaq's loss after Credit Suisse raised its price target on the stock by $25 to $300, citing strength in the tech company's iPhone unit.

Another upside influence was RadioShack , which gained after a report that it was exploring alternatives including a share buyback or a possible sale of the U.S. electronics retailer that could net more than $3 billion. The stock jumped 8.5 percent to $23.65.

About 8.61 billion shares traded on the New York Stock Exchange, the American Stock Exchange and Nasdaq, below last year's estimated daily average of 9.65 billion.

There were roughly an equal number of advancers and decliners on the New York Stock Exchange, while on the Nasdaq, slightly more stocks fell than rose.