Stocks End Higher as Techs Rise

Stocks eked out a gain Thursday, led by technology and consumer staples, after struggling all day as data on regional factory activity and jobless claims underscored worries about the pace of the economic recovery.

The Dow Jones Industrial Average ended up more than 20 points, after gaining less than five points in the previous session.

Both the S&P 500 and the tech-heavy Nasdaq also ended higher. The CBOE volatility index, widely considered the best gauge of fear in the market, rose above 26.

Consumer staples and technology were the best performers on the S&P, while consumer discretionary and materials were among the weakest links.

Some experts cautioned investors about a short-term pullback.

“There’s a good chance that we’re going to test the May lows at sometime later in the summer, but if you look out into the year-end, I think we’ll be 5 to 10 percent higher,” Maury Fertig, CIO of Relative Value Partners, told CNBC.

Although Fertig is concerned about the uneven economic recovery and news out of the euro zone, he is using the weaknesses as buying opportunities.

In the day's economic news, jobless claims rose by 12,000 last week; economists had expected to see a decline. A separate report showed the Philly Fed manufacturing gauge tumbled to 8.0 from 21.4 in May, its slowest pace in 10 months.

Plus, leading indicators rose 0.4 percent and consumer prices fell 0.2 percent, both in May. Excluding volatile food and energy costs, however, prices rose 0.1 percent.

Shares of most gold miners including Barrick Gold and Kinross Gold rose around 4 percent after gold settled at a record closing highof $1,248.70, as a combination of concern over the impact of the euro zone crisis and series of weak U.S. economic encouraged a fresh sweep into safe-haven assets.

The euro climbed to a three-week highagainst the dollar after a Spanish bond auction of 10- and 30-year notes was met with strong demand, which helped assuage concerns about the nation's ability to meet its debt obligations this year. Meanwhile, oil prices settled at $76.79 a barrel.

Shares of BP fell after the company agreed to set aside $20 billion in escrow for claims against the oil spill and as CEO Tony Hayward was grilled on Capitol Hill.

  • Watch a live video feed of the hearing

The $20 billion pricetag could grow much faster in coming months if the Justice Department files criminal charges against the company. Even misdemeanor convictions under environmental laws could produce large fines under general federal criminal statutes, which could inflate BP's total bill.

Bank of America-Merrill Lynch downgraded BP to "neutral" from "buy" on fears that the cleanup costs will make the company less competitive. Barclays Capital also cut BP to "underweight" on concerns over cleanup costs.

Analysts were divided, though, with Credit Suisse raising its view on the company and Citigroup saying BP can meet its financial obligations.

Big banks, including Bank of America, JPMorgan and Citigroup , were higher amid buzz that the banks may put an end to free checkingfor customers to make up for lost revenue due to tighter regulations on other fees.

But U.S.Bancorp shares fell after Rochdale Securities analyst Dick Bove cut his price target on the bank to $27 from $29.50. This follows other price target cuts that Bove issued earlier last week on JPMorgan, Bank of America and Goldman Sachs.

Credit Suisse also cut its price target on Goldman Sachs to $225 from $235.

Meanwhile, Apple rose to a record near $273 after the company said it sold more than 600,000 of its new 4G iPhones in one day — a new record.

U.S.-traded shares of Nokia rose, despite at least two brokerages cutting their price target on the Finnish handset maker.

Other tech stocks such as Qualcomm and Dell were also higher.

Homebuilders skidded after a brokerage downgraded five stocks in the sector, including KB Home , to "sell."

Ford shares fell despite the latest report from J.D. Power Initial Quality Study stating that the U.S. auto maker rose to the fifth spotin terms of brand quality, ahead of both Honda and Toyota . The first time ever Ford has cracked the top 5.

On the earnings front, Aetnaraised its second-quarter forecast, driven by better-than-expected underwriting margins amid higher health-care costs, and grocery chain Kroger backed its full-year outlook.

This was encouraging, particularly after FedEx and Nokia delivered disappointing outlooks a day earlier.

Some investors worried that the FedEx outlook was a bad omen for earnings season— that more companies may follow and that it could signal a double-dip is coming.

But Nadav Baum, executive vice president at BPU Investment Management in Pittsburgh, said don’t read too much into individual warnings as it's "not a reflection on the economy or the market."

Two IPOs debuted above their offering prices today — oil and gas exploration company Oasis Petroleum and college banking-services firm Higher One Holdings . But mobile Internet and data firm Motricity slashed the size of its IPO and delayed pricing it for a day. That stock will trade under the symbol "MOTR."

Still to Come:

FRIDAY: Quadruple witching; S&P indexes rebalanced

More From CNBC.com: