Stocks End Higher, but Close Lower for Week

Stocks closed higher in thin trading Friday, but snapped a two-week rally amid ongoing uncertainty over the government's ability to reach a debt-reduction deal and some growing concerns over the economy.

The Dow Jones Industrial Average gained 42.61 points, or 0.34 percent, to finish at 12,479.73, after see-sawing for most of the session.

The S&P 500 rose 7.27 points, or 0.56 percent, to close at 1,316.14.

The tech-heavy Nasdaq climbed 27.13, or 0.98 percent, to end at 2,789.80.

The CBOE Volatility Index, widely considered the best gauge of fear in the market, finished near 20.

For the week, the Dow fell 1.4 percent, the S&P declined 2.06 percent, while the Nasdaq slid 2.45 percent.

Energy was the only gainer for the week among S&P sectors, while financials were the biggest laggards. For the week, ExxonMobil was the biggest gainer on the blue-chip index, while BofA lagged for the second week.

Citigroup slipped after the bank's profits surged, topping estimates, as the firm's revenue was essentially flat from the previous year. Rivals JPMorgan and BofA also fell.

Eight banks—including two Greek banks, five Spanish and one Austrian bank—have failed the European Banking Authority's (EBA) stress tests, according to the agency.

Meanwhile, Standard & Poor's put a broad range of financial firms on negative credit watch, warning they could all be downgraded if the U.S. has its credit rating cut.

The rally lost steam after consumer sentiment fell in July to the lowest level since March 2009amid increasing pessimism over falling income and rising unemployment, according to the Thomson Reuters/University of Michigan survey.

"Of course sentiment is lower," according to Todd Schoenberger, managing director of LandColt Trading. "The only surprise here is the number didn't drop nearly as much as it should have!"

"Macro data has been horrible the past couple of months... [Jobless] claims at 405,000 isn't a bright spot—14 straight weeks we've been north of 400,000," Schoenberger explained. "EPS growth rate for this earnings season is expected to be 13.5 percent, the slowest since the recession, dare I say it, ended!"

Also among earnings, Google soared to lead the S&P 500 leaders after the search-engine giant reported earnings that exceeded even the most bullish forecasts. At least three brokerages raised their price target on the search-engine giant. Chinese "Google" Baidu also traded higher.

A slew of earnings are expected next week with nearly half the firms on the Dow such as Coca-Cola , BofA and Microsoft poised to report. Other notable firms include Goldman Sachs and Apple .

Apple gained after at least two brokerages raised their price targets on the iPod maker. IBM also rose after Collins Stewart raised its price target on the tech giant to $200 from $185.

Gold reach an all-time high, soaring $48.60, or 3.15 percent, this week to settle at $1589.80 an ounce. Oil prices gained as U.S. light, sweet crude rose near $97 a barrel and London Brent crude climbed above $117.

Most energy stocks were higher, including Chesapeake , Nabors and Hess.

In M&A news, Petrohawk Energy skyrocketed more than 60 percent after mining group BHP Billiton said it will buy the gas producer for $12.1 billion.

And Clorox jumped after billionaire investor Carl Icahn offered to buy the firm for $10.2 billion. And S&P raised its price target on the household goods producer to $77.

Meanwhile, investigations are progressing into the U.S. operations of News Corp after the UK phone hacking scandal. And News International’s chief executive Rebekah Brooks finally bowed to political pressure tendering her resignation.

Zillow raised the price range of its initial public offering to $16 to $18 per share from $12 to $14 per share. The real estate and housing data company filed with the U.S. securities regulators for an IPO of up to $51.8 million in April.

GOP lawmakers said the House of Representatives is to vote next week on a plan to raise debt ceiling with equal cuts. Five rounds of talks this week still produced no agreement with the talks likely to resume over the weekend.

"Show me a plan in terms of what you're doing in terms of debt and deficit reduction. If they show me a serious plan I'm ready to move even if it requires me to make some tough decisions," Obama said during a White House press conference.

Volume continued to be light with the consolidated tape of the NYSE at 3.87 billion shares, while 1.07 billion shares changed hands on the floor.

On the economic front, however, a gauge of manufacturing in New York State showed the sector unexpectedly contracted for the second month in a row. Meanwhile, U.S. consumer prices fell slightly more than expected in June to post their biggest drop in a year on weak gasoline costs.

Industrial production rose in June for the first time in three months after revisions, on a jump in utilities and mining output, according to a Fed study.

On Tap Next Week:

MONDAY: Treasury international capital, housing market index; Earnings from Halliburton and IBM
TUESDAY: Housing starts, Fed's Hoenig speaks; Earnings from BofA, Coca-Cola, Goldman Sachs, J&J, Wells Fargo, Apple and Yahoo
WEDNESDAY: Weekly mortgage apps, existing home sales, oil inventories; Earnings from Altria, United Tech, Abbott Labs, Blackrock, AmEx, Intel, Qualcomm and Ebay
THURSDAY: Weekly jobless claims, Philadelhia Fed survey, money supply; Earnings from AT&T, Morgan Stanley, Nokia, PepsiCo, Freeport McMoran, Travelers, Mircrosoft, AMD and SanDisk
FRIDAY: No major econ. news expected; Earnings from Caterpillar, GE, McDonald's, Schlumberger, Verizon, Honeywell

More on CNBC.com