The Dow Jones industrial average and the Standard & Poor's 500 index had a winning week for the first time this month.
"There's been a wrestling match all week long between strong earnings and weak economic data," said Lawrence Creatura, a portfolio manager at Federated Investors, the money-management firm. "At the moment, earnings are winning."
Before the market opened, McDonald's posted better quarterly profits, buoyed by warm weather and sales of new menu items like Chicken McBites and oatmeal. Sales picked up even in Europe, McDonald's' biggest market, despite economic turmoil and severe weather.
Microsoft beat analysts' projections with quarterly earnings and revenue, and sales in its Windows division were surprisingly strong. And General Electric posted a profit of more than $3 billion, helped by orders for locomotives, aircraft engines and other equipment.
The Dow rose 65.16 points to close at 13,029.26. The S&P 500 added 1.61 points to 1,378.53.
Corporate earnings results have provided a pleasant surprise, said Sam Stovall, chief equity strategist at S&P Capital IQ. After nine straight quarters of growth, earnings for S&P 500 companies were expected to be nearly flat. But eight of every 10 companies that have reported so far, including Coca-Cola and IBM, have beaten estimates. As a result, first-quarter earnings are now projected to rise 4.4 percent, according to S&P.
In Europe, Germany's DAX rose 1.2 percent, and stock indexes in France and Spain were higher. A closely watched survey in Germany, the continent's economic powerhouse, showed business optimism rising for the sixth straight month. Economists had expected a decline.
In other U.S. trading, Apple sank 2.5 percent, helping to tug the Nasdaq composite index down 7.11 points to 3,000.45. Apple, the most valuable company in the world, accounts for 12 percent of the Nasdaq.
The Dow gained 1.4 percent this week, and the S&P 500 index 0.6 percent. But it wasn't a smooth ride. Better earnings reports and higher retail sales helped drive the stock market up to start the week. The Dow rose 194 points on Tuesday, its best day in more than a month.
Then worries about Europe came storming back. Markets reversed course Wednesday, after the Bank of Spain said that the amount of bad loans held by Spanish banks rose to an 18-year high.
If those banks falter, it would put pressure on Spain's already troubled government to prop them up. Weak reports on jobs, housing and manufacturing in the U.S. added to the selling pressure, and the Dow slumped 151 points in two days.
"It's been like the weather here in upstate New York -- unpredictable," Creatura said. "One day is up, the next day is down."
The encouraging news out of Germany helped drive oil prices up Friday. Benchmark U.S. crude rose 78 cents to finish at $103.05 per barrel in New York. Brent crude, widely used by U.S. refiners to produce gasoline, added 76 cents to $118.76 in London.
Among stocks making big moves in the United States:
-- Oil services giant Schlumberger Ltd. rose 3 percent. The company's quarterly profits jumped almost 38 percent as strong drilling activity in the Gulf of Mexico and the Middle East offset a slowdown in North America's natural gas fields. Schlumberger said that world oil demand appears to have "stabilized" and that the risk of a double-dip recession has declined.
-- E-Trade Financial Corp. jumped 6 percent, the largest gain in the S&P 500. The online broker reported a 40 percent jump in first-quarter profit after the close of trading Thursday, beating Wall Street estimates with the help of a big tax benefit.
-- SanDisk Corp. plummeted 11 percent, the S&P's biggest loser. The flash memory maker said late Thursday that weak demand and low prices cut its quarterly profit by nearly half. SanDisk warned that it expects the trend to continue.
-- Tempur-Pedic International Inc., the mattress maker, plunged 20.6 percent after posting a disappointing full-year earnings forecast. It cited concerns about competition and foreign exchange rates.
MORE HBJ HEADLINES
Our new comment system is not supported in IE 7. Please upgrade your browser here.