NEW YORK (CNN/Money) -
Stocks rallied Wednesday, managing a big last-hour comeback after a tough session in which rising oil prices and earnings jitters kept the major gauges rangebound and jittery.
After the close, Apple Computer (Research) reported quarterly earnings, sales, margins and iPod shipments that topped expectations, sending its shares as much as 13 percent higher in after-hours trading.
The Dow Jones industrial average (up 61.56 to 10,617.78, Charts) and the Nasdaq composite (up 12.91 to 2,092.53, Charts) both gained around 0.6 percent Wednesday.
The Standard & Poor's 500 (up 4.71 to 1,187.70, Charts) index saw slightly smaller gains.
Stocks started the session on a positive footing, following Intel's upbeat earnings and forecast. But any good cheer soon evaporated, amid rising oil prices and a morning report that showed a surprise widening of the deficit.
Most of the session saw the indexes swaying between flat and negative, until a rally near the close turned the tide back to positive.
The turnaround was mostly technical in nature, said Paul Mendelsohn, chief investment strategist at Windham Financial Services.
"I think the market had gotten very oversold, and you just saw some big institutions stepping in during the last hour," he said.
The falling dollar may have helped as well, as it provided support to oil and commodities stocks, as well as to tech.
Stocks could continue to rise Thursday, Mendelsohn said, particularly following Apple's strong earnings report, but the market direction beyond that may be dictated by the slew of economic news due Thursday and particularly Friday, and the spate of quarterly earnings that start pouring in next week.
Thursday's big economic report of note is the December retail sales report, which encompasses the key holiday sales period.
Sales for the month are expected to have risen 1.1 percent, according to a Briefing.com survey of economists. Sales rose 0.1 percent in November. Sales excluding autos are expected to have risen 0.4 percent after rising 0.5 percent in November.
With the exception of a small advance Monday, stocks have been flat to weaker since the start of the new year. Stocks tumbled more sharply Tuesday after disappointing earnings results from Alcoa and Genentech and a sales warning from Intel rival Advanced Micro Devices.
But the news was more positive after the bell Tuesday, at least for technology. Chip leader Intel (up $0.62 to $23.16, Research) reported fourth-quarter earnings and sales that topped estimates. The company also issued first-quarter sales guidance in a range that sets the midpoint higher than what analysts had been expecting.
Intel shares gained 2.75 percent and helped spark a mild rally for the chip sector, although not as substantial a rally as had been anticipated.
The Philadelphia Semiconductor (up 5.64 to 401.83, Charts) index, or the SOX, gained around 1 percent.
In addition to Intel, a number of other big-cap tech stocks rose near the close, giving the Nasdaq support.
eBay (up $2.41 to $107.25, Research), Yahoo! (up $0.48 to $36.14, Research) and other Internet issues rose, boosting the Goldman Sachs Internet (Charts) index by 2.25 percent.
Stun gun maker Taser (up $2.91 to $17.01, Research) rallied more than 20 percent, rebounding after Tuesday's steep slide on worries about lower orders in the quarter.
HCA (up $4.02 to $43.70, Research) rose 10 percent in active New York Stock Exchange trade after the hospital operator said fourth-quarter earnings will beat earlier forecasts.
On the downside, package delivery company UPS (down $6.12 to $77.18, Research) warned late Tuesday that fourth-quarter earnings per share will come in lower than previously expected, missing analysts' estimates.
UPS shares fell more than 7 percent in active New York Stock Exchange trade and dragged down the Dow Jones Transportation index by around 1.6 percent.
Dow component Verizon Communications (down $0.37 to $38.23, Research) lost around 1 percent after Goldman Sachs downgraded the stock to "in line" from "outperform," citing the stock as an exception in an otherwise upbeat note on telecom gear makers.
On the upside, stun gun maker Taser (up $2.91 to $17.01, Research) rallied 19 percent in active Nasdaq trade, rebounding after Tuesday's steep slide on worries about lower orders in the quarter.
HCA (up $4.02 to $43.70, Research) rose 9 percent in active New York Stock Exchange trade after the hospital operator said fourth-quarter earnings will beat earlier forecasts.
Market breadth turned positive after having been negative for most of the session. On the New York Stock Exchange, advancers beat decliners nine to seven on volume of 1.55 billion shares. On the Nasdaq, losers topped winners eight to seven on volume of 2.25 billion shares.
Adding to the session's hesitant nature was a report showing that the November trade gap widened to a record $60.3 billion, when economists thought it would narrow to $54 billion. The trade deficit stood at a revised $56 billion in October.
Oil prices rose after a mixed weekly inventory report, released around 10:30 a.m. ET. U.S. light crude oil for February delivery gained 69 cents to settle at $46.37 a barrel on the New York Mercantile Exchange; the contract was as high as $46.60 before retreating.
Treasury prices were barely higher, pushing the yield on the 10-year note down to 4.23 percent from 4.24 percent late Tuesday. Treasury prices and yields move in opposite directions.
In currency trading, the dollar fell versus the euro and yen, reacting to the surprise widening of the trade gap.
COMEX gold rose $4.20 to settle at $426.60 an ounce, rising with other dollar-traded commodities.