A late-day rally Wednesday erased much of a massive sell-off triggered earlier in the session by a surge in crude oil prices to 21-year highs and disappointing economic news. Blue chip stocks managed to close higher, but tech stocks still lagged.

The Dow Jones industrial average (search) gained 31.93 points, or 0.32 percent, at 10,117.07. The Standard & Poor's 500 Index (search) rose just 0.59 of a point, or 0.05 percent, at 1,095.42. The technology-laced Nasdaq Composite Index fell 10.84 points, or 0.58 percent, at 1,858.26.

High oil prices kept investors on edge for most of the session, after U.S. light crude for September delivery rose to a 21-year high of $43.05 a barrel -- topping peaks hit in early June. September crude oil settled at $42.90 a barrel, up $1.06, on the New York Mercantile Exchange (search).

The price jump followed news that bailiffs ordered beleaguered Russian oil giant Yukos to stop sales, threatening further strain on tight international supplies.

A vital ingredient in the production of most goods and services as well as transport, higher crude prices immediately hurt profits at most companies. The rising price of oil has also weighed on the economy in recent months.

"The concern over oil is related to economic growth and corporate profits -- that this will take some more steam out of an economy that already seems to be slowing," said Owen Fitzpatrick, head of U.S. equity group, Deutsche Bank Private Wealth Management.

The oil-price hike sent the Dow Jones industrial average back below the psychologically important 10,000 level during the session, while the S&P 500 tested the 2004 low set on Monday of 1,084.07 and the Nasdaq slid nearly 2 percent.

Some analysts doubted the late rally's conviction, attributing it to programmed trading — when large investment houses automatically purchase shares because they've reached a pre-set buying point — and simple bargain hunting after four weeks of selling.

"The valuations on the Standard & Poor's 500 are at a level we haven't seen since 1995, which is pretty impressive if you're out there shopping for stocks," said Thomas F. Lydon Jr., president of Global Trends Investments in Newport Beach, Calif. "However, the average investor doesn't have the confidence to do real buying in this market. It was nice to see the reversal ... but the fundamentals still tend to be on the negative side."

The Commerce Department (search) reported orders to U.S. factories for big-ticket items rose 0.7 percent in June, slightly lower than what analysts had forecast. But the gain in orders for durable goods — items expected to last three or more years — was good news after two months of declines, as it offered some hope that the rebound in the nation's manufacturing sector is no longer in danger of stalling.

Investors were less than impressed, however, after a number of business barometers showed signs of weakness last month. Most analysts agree the slowdown is likely temporary, but trading has been lackluster through the current earnings season due to a number of downbeat outlooks.

"The durable goods number is not only less than expected but the previous two months were well short of expectations," said Bill Strazzullo, chief market strategist at State Street Corp. "One of the concerns the market has is whether there will be a significant pickup in business spending and these last three months call that into question."

While the oil situation didn't help the market, analysts said the day's mostly downward trend — which followed a sharply positive session Tuesday — simply extended a months-old pattern, in which poor performance in the tech sector led the rest of the market lower. Much of the anxiety has been focused on semiconductors; because chips are used in virtually all tech products, any weakness in that industry is seen as bad news for the rest of the sector. The Philadelphia Semiconductor Index closed down 0.9 percent, recovering from the day's low.

"In general, the view on street is that things are slowing down, and no one is confident about the forecasts of the semis," said Steven Goldman, chief market strategist with Weeden & Co. in Greenwich, Conn. "It's continuing to move lower, it hasn't stabilized, and the market's at the point where it's not going to shrug it off any further."

Among the day's best advancers, Boeing Co. (BA) gained 79 cents to $49.01 after reporting better-than-expected profits and raising its forecasts for the rest of this year and next, thanks in part to an improving outlook for the long-stagnant commercial airplane business. The nation's largest aerospace company said it expects to deliver more jets than previously forecast in 2005.

Time Warner Inc. (TWX) was down 26 cents at $16.65 after reporting profits that were ahead of expectations, and a boost in revenues thanks to the latest Harry Potter movie and its cable services and networks. The media conglomerate, which operates CNN, Warner Bros. and HBO, lost more customers from its long-troubled America Online division, but advertising buoyed revenues and profits there as well.

Shares in Comcast Corp. (CMCSA), the largest U.S. cable operator, fell $1.18 to $27.56. Although the company beat analyst estimates by 2 cents a share, it disappointed investors by scaling back an earlier forecast that it would add 10,000 subscribers in 2004.

Manufacturing and chemical stocks, seen as susceptible to oil-price hikes, were hurt. 3M Co. (MMM) fell $1.06 to $81.99 while DuPont Co. (DD) dipped 6 cents to $42.25.

While a record-high oil price is bad news for the overall market, it is good news for energy companies and energy stocks shot higher. Exxon Mobil (XOM) was up 40 cents, or 0.88 percent, at $45.81, ChevronTexaco (CVX) rose 46 cents, or 0.49 percent, to $94.31, and oil services firm Baker Hughes Inc. (BHI) gained 31 cents, or 0.79 percent, to $39.54.

Consumer products maker Procter & Gamble Co. (PG) fell 45 cents to $53.44 after Anglo-Dutch competitor Unilever reported lower-than-expected second-quarter operating profit and sales on Wednesday.

Trading was active, with about 1.6 billion shares changing hands on the New York Stock Exchange and about 1.8 billion shares traded on Nasdaq.

The Russell 2000 index, which tracks smaller company stocks, was down 3.41, or 0.6 percent, at 541.20.

Overseas, Japan's Nikkei stock average finished 1.6 percent higher Wednesday. In Europe, France's CAC-40 added 0.3, Britain's FTSE 100 rose 0.7 percent and Germany's DAX index declined 0.2 percent.

Reuters and the Associated Press contributed to this report.