It was a quiet end to an eventful week. Markets around the world rallied on Monday after Greece and its creditors agreed to a broad framework for a new loan program. Stronger quarterly earnings reports from a range of big U.S. companies, including Citigroup and JPMorgan Chase, added more encouragement.
"It appears the sky is clearing," said Linda Duessel, senior equity strategist at Federated Investors.
Before this week, concerns about China's plunging stock market and the prospect of Greece leaving the euro "had been bogging us down," she said.
The Standard & Poor's 500 index edged up 2.35 points, or 0.1 percent, to close at 2,126.64. The broad-market measure finished the week with a gain of 2.4 percent, its best performance in four months.
The Nasdaq rose 46.96 points, or 0.9 percent, to 5,210.14, closing out its best week in nine months. The Dow Jones industrial average lost 33.80 points, or 0.2 percent, at 18,086.45.
Google jumped after reporting profits and sales that topped analysts' forecasts late Thursday. The results ended six consecutive quarters in which Google's earnings fell short of analysts' targets. Google rose $97.84, or 16 percent, to $699.62.
Earnings reports out this week have looked better than Wall Street expected. Analysts forecast that second-quarter earnings will shrink 3.3 percent compared with the prior year, according to S&P Capital IQ. Last week, the prediction was for a drop of 4.4 percent.
Greece's deal cleared another hurdle on Friday when German lawmakers overwhelmingly backed it. The European Union also said it would get Athens enough money for it to keep making its debt payments.
Europe's major markets finished mixed after rallying earlier this week. Germany's DAX lost 0.4 percent while France's CAC edged up 0.1 percent. Britain's FTSE 100 slipped 0.3 percent.
Back in the U.S., Comerica reported a drop in quarterly earnings, partially a result of the Dallas-based bank setting aside more money to cover losses on loans to oil companies. The news drove Comerica's stock down $3.19, or 6.3 percent, to $47.28.
Bond prices barely moved, leaving the 10-year Treasury note at 2.35 percent. The dollar dropped to 124.06 yen while rising to $1.0838 for every euro.
In commodities trading, precious and industrial metals sank. Gold fell $12 to settle at $1,131.90 an ounce, while silver sank 15 cents to $14.92 an ounce. Copper fell 3 cents to $2.50 a pound.
Benchmark U.S. crude oil fell two cents to close at $50.89 a barrel in New York. Brent crude, the international benchmark, rose 18 cents to close at $57.10 a barrel in London.
In other trading on the New York Mercantile Exchange:
— Wholesale gasoline rose 3.2 cents to close at $1.929 a gallon.
— Heating oil fell 0.2 cent to close at $1.664 a gallon.
— Natural gas increased 1.6 cents to close at $2.870 per 1,000 cubic feet.