Updated

Stocks managed to post modest gains Tuesday, despite another jump in oil prices, on the strength of reassuring a consumer price report that put many investors' inflation fears to rest for the near term.

The Dow Jones industrial average (search) ended up 18.28 points, or 0.18 percent, at 9,972.83, while the tech-heavy Nasdaq Composite Index (search) closed 12.41 points higher, or 0.70 percent, at 1,795.25. The broader Standard & Poor's 500 Index (search) added 2.37 points, or 0.22 percent, at 1,081.71.

After receding on Monday, NYMEX crude oil futures (search) ended just below a new record Tuesday as the inflation data gave traders hope that high oil prices may not yet be hurting economic growth. In addition, an inventory report due Wednesday is expected to show that crude supplies shrank, according to analysts.

NYMEX September crude traded at $46.72 a barrel, after earlier hitting $46.95, the highest level crude futures have reached in the 21 years they have traded on the exchange. The previous record of $46.91 was set overnight Monday.

Crude oil is a vital ingredient in the production of many goods and services as well as transport. Price fluctuations ripple through the U.S. economy, hurting profits at most companies whenever prices jump higher.

But upbeat economic reports helped to offset the surge in oil prices.

With gasoline prices falling to eight-month lows, the Consumer Price Index (search) registered a small drop in July, giving consumers a respite from soaring energy prices. With consumer spending one of the main drivers of the economy, the news cheered investors who have been concerned that higher oil prices could spur inflation.

"You're going to get some naysayers out there, saying this is just one month, hedging against anything bad coming up, but really, this is great news," said Bill Groenveld, head trader with vFinance Investments. "I think this could be the start of a smooth, cautious recovery."

The consumer price index, the most widely used gauge of U.S. inflation, slid 0.1 percent in July, the Labor Department (search) said. It was the first decline in consumer prices since November. The so-called core CPI, which strips out volatile food and energy costs, inched up just 0.1 percent.

Housing starts rose a healthy 8.3 percent to a seasonally adjusted annual rate of 1.978 million units in July, above Wall Street expectations.

The economic data reaffirmed that, despite soaring energy costs, the overall economy remained sound and that inflation, at least for now, has been kept at bay. And if oil prices fall from their current record highs, stocks will be poised to make strong gains, analysts said.

"In the short term, there's enough good news in the economic data to offset oil prices, at least for now," said Chris Wolfe, global head of equities for J.P. Morgan Private Bank. "Certainly, we can't see how these oil prices will be sustainable in the long term. We're ready for a relief rally once the prices start coming down."

Motorola Inc. (MOT) the world's second-largest mobile phone maker, helped markets after a top executive said in an interview that the company expects strong sales growth in the second half of 2004. Shares of Motorola rose 66 cents, or 4.6 percent, to $15.08.

Dow component Home Depot (HD) surged $1.12 to $35.10 after the home improvement retailer reported record sales and a 19 percent increase in second-quarter profits. Home Depot beat Wall Street expectations by 7 cents per share and raised its guidance for future quarters.

Office supply chain Staples Inc. (SPLS) saw its profits rise 39 percent in the quarter, beating expectations by 2 cents per share. Staples, which also announced new ventures in Europe and China, gained 99 cents to $28.87.

Consumer wholesaler B.J.'s Wholesale Club Inc. (BJ) was up $1.77 at $25.16 after reporting a strong 25 percent rise in second-quarter earnings. The company beat estimates by 5 cents per share.

J.C. Penney Co. (JCP) matched Wall Street estimates, managing a small profit for the quarter after breaking even a year ago. Penney slipped 27 cents to $38.48 after trading in positive territory most of the day.

Shares of Halliburton Co. (HAL) fell after the U.S. Army said it will withhold payment on 15 percent of future invoices of Halliburton's logistics deal in Iraq due to a billing dispute that could cost the company $60 million a month. Halliburton's stock fell 49 cents, or 1.8 percent, to $27.30

Trading was moderate, with 1.3 billion shares changing hands on the New York Stock Exchange, just below the 1.4 billion daily average for last year. About 1.4 billion shares were traded on Nasdaq, under the 1.7 billion daily average last year.

Advancers outnumbered decliners by nearly 5 to 3 on the NYSE and almost 3 to 2 on Nasdaq.

The Russell 2000 index of smaller companies was up 1.94, or 0.4 percent, at 530.00.

Overseas, Japan's Nikkei stock average rose 0.3 percent. In Europe, Britain's FTSE 100 closed up 0.2 percent, France's CAC-40 gained 0.5 percent for the session and Germany's DAX rose 0.2 percent.

Reuters and the Associated Press contributed to this report.