Updated

U.S. stocks rose on Tuesday, erasing early session losses in an afternoon rally triggered by a surge in shares of KLA-Tencor Corp. (KLAC) after the semiconductor equipment company said orders were rising more than it expected.

The Dow Jones industrial average rose 31.22 points, or 0.28 percent, to end at 11,134.77. The Standard & Poor's 500 Index advanced 5.18 points, or 0.41 percent, to finish at 1,272.52. The Nasdaq Composite Index gained 11.93 points, or 0.56 percent, to close at 2,128.86.

Click here to visit FOXBusiness.com's Investing Center.

Stocks had spent much of the day deep in the red after sales from Dow component Alcoa Inc. (AA) and a warning from Lucent Technologies Inc. (LU) disappointed some investors. News of a series of deadly bombings in Mumbai, India's financial hub, also rattled Wall Street.

Stronger-than-expected earnings from Pepsi Bottling Group Inc. (PBG) drove its stock to a four-year high and contributed to greater optimism about corporate earnings. A rise in oil prices that carried energy stocks higher added to the market's turnaround.

"KLA-Tencor came out with some bullish comments, and that helped provide a lift for the semiconductor group which... spread to other sectors, and by the end of the day, the market closed in the green," said Michael Sheldon, chief market strategist at New York brokerage Spencer Clarke.

KLA-Tencor shares shot up 8.2 percent, or $3.23, to $42.56 on the Nasdaq.

Exxon Mobil's (XOM) stock gained 1.5 percent, or 94 cents, to $63.98 on the New York Stock Exchange as U.S. crude for August delivery gained 55 cents to settle at $74.16 a barrel after Iran rebuffed demands to halt uranium enrichment.

Pepsi Bottling shares rose 5 percent, or $1.61, to $33.96 after the company posted higher-than-expected second-quarter profit and raised its 2006 outlook.

But sentiment was still dampened as disappointing sales from aluminum maker Alcoa Inc. and a profit warning from Lucent Technologies Inc. dimmed investors' optimism about second-quarter earnings.

As the first Dow component to report quarterly profits, Alcoa is often seen as a bellwether for the earnings reporting season. Alcoa was the biggest drag on the Dow on Tuesday, falling 4.9 percent, or $1.63, to $31.78, a day after the world's largest aluminum maker reported quarterly sales below Wall Street's estimates.

Communications-equipment maker Lucent said late on Monday it expected third-quarter earnings to fall, sending the company's shares down 6.4 percent, or 15 cents, to $2.19.

"There's still so much uncertainty out there ... What are second-quarter earnings going to look like?" said Mike Driscoll, Bear Stearns listed trader and managing director, in New York.

U.S.-listed shares of major Indian companies, like Tata Motors Ltd., fell after scores died in a series of bombings on commuter trains in Mumbai, India's financial hub.

Tata shares fell 2.8 percent, or 48 cents, to $16.50 on the Nasdaq.

Volume was moderate on the NYSE, where about 1.57 billion shares changed hands, slightly below last year's daily average of 1.61 billion. On Nasdaq, about 2.05 billion shares traded, above last year's daily average of 1.80 billion.

Advancing stocks outnumbered declining ones by a ratio of about 7 to 4 on the NYSE, and by about 17 to 13 on the Nasdaq.

Click here to visit FOXBusiness.com's Investing Center.