After being down more than 150 points in the morning, the Dow Jones industrial average ended the day with a gain of 3 points. That was just enough for the index to end higher for a fifth week.
The S&P 500 added 1 point, closing just below its all-time high. For the week, however, the S&P ended basically unchanged.
The Nasdaq gained 8 points for the day, and nearly 1% for the week.
After a pullback in June, stocks hit record highs this month as Chairman Ben Bernanke and other Fed officials downplayed concerns about the central bank's $85 billion-per-month bond buying program.
This week, investors sifted through a slew of reports on corporate earnings and rewarded companies that beat expectations.
But the tone was cautious Friday as investors looked ahead to next week's meeting of top Fed officials and the government's monthly jobs report.
"Investors are taking profits now and waiting to see how next week shakes out," said J.J. Kinahan, chief derivatives strategist at TD Ameritrade. "Why take unnecessary risk heading into it?"
Earnings are a mixed bag: Tech shares have been the biggest drivers this week, boosted by strong earnings from Apple (Fortune 500) and , Facebook (. But weak results from )Amazon (Fortune 500) and , Expedia ( put pressure on the sector Friday. )
Expedia shares plunged after the online travel company plunged 24% on a worse-than-expected earnings report.
Amazon shares were lower after the online retailer posted a surprise loss. And Zynga's ( stock sank after the online gaming company issued a weak outlook for the third quarter and said it's not going to pursue )online gambling in the United States.
But the losses were offset by shares of Activision Blizzard (, which surged more than 21% after the )maker of games such as World of Warcraft and Call of Duty said it was striking out on its own through an $8.2 billion deal.
Starbucks (Fortune 500) shares rose after the coffee merchant delivered better-than-expected quarterly earnings and sales. ,
Halliburton (Fortune 500) stock rose nearly 4% after the Justice Department said the , oilfield services firm would plead guilty to destroying computer test results that had been sought as evidence in the Deepwater Horizon disaster.
Tesla Motors ( shares gained after ) Deutsche Ban (k upgraded the electric car maker. )
More than half of the companies in the S&P 500 have reported results for the second quarter, with 66% of them topping analysts expectations, according to S&P Capital IQ.
Earnings growth has been strongest in the financial and consumer discretionary sectors, while materials and telecommunications companies have seen profits decline.
In economic news, the University of Michigan and Thomson Reuters said a key measure of consumer sentiment rose to 85.1 in July, the highest level in six years.
Overseas markets: European markets ended mostly lower, though shares of Pearson ( and )LVMH ( rose after the companies posting better-than-expected earnings. )
|2 million Facebook, Gmail and Twitter passwords stolen in massive hack|
|Fresh fast food strikes planned for Thursday|
|Ron Paul: Bitcoin could 'destroy the dollar'|
|Apple completes key China Mobile deal - report|
|GDP revised up, but not as good as it looks|
|Overnight Avg Rate||Latest||Change||Last Week|
|30 yr fixed||4.52%||4.38%|
|15 yr fixed||3.55%||3.42%|
|30 yr refi||4.51%||4.37%|
|15 yr refi||3.54%||3.41%|
Today's featured rates: