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. )
|Mark Zuckerberg calls Obama to complain about NSA|
|Microsoft's next big headache: The Google Chromebook|
|McDonald's workers sue for wage theft|
|Amazon increases price of Prime|
|Military widow still waits for death benefits|
|Overnight Avg Rate||Latest||Change||Last Week|
|30 yr fixed||4.29%||4.39%|
|15 yr fixed||3.35%||3.42%|
|30 yr refi||4.30%||4.40%|
|15 yr refi||3.33%||3.40%|
Today's featured rates: