NEW YORK, OCT. 3 -- Propelled by a last-minute buying spree, the price of oil rebounded sharply today, making up most of its losses of earlier in the week.

Oil traders and analysts said market optimism about peace in the Middle East was replaced by a new round of nervousness and uncertainty.

The price of a benchmark barrel of high-quality crude oil on the New York Mercantile Exchange shot up $3.37 a barrel, to $37.32, after falling a total of $5.56 the two previous sessions. Prices of gasoline and heating oil also went up sharply on the commodities exchange.

Traders and analysts said the rise was fueled by an American Petroleum Institute report that U.S. crude oil inventories had fallen 9.4 million barrels last week, almost as much as the decline in the previous two weeks combined. There also were worries about the implications of the postponement of a scheduled United Nations speech by Iraq's foreign minister.

More than half of today's increase in crude prices came in a surge in the last 20 minutes of trading. Analysts said many traders who bailed out on the way down earlier this week apparently decided to jump back into the market when they saw prices rebounding.

"We started to see some buying come back into the market," said Tom Bentz, trading director at United Energy Inc. here. "Before you know it, you've got everybody jumping on the bandwagon trying to get in."

The price drop this week had been spurred by signs that Iraqi leader Saddam Hussein might be willing to negotiate the standoff with the United States over the Iraqi occupation of Kuwait, but analysts said yesterday those signs seemed to be fading, renewing fears that war in the region will cause a major oil shortage.

"People {got} nervous again and the 'war premium' came back," said Ann-Louise Hittle, a senior oil analyst at Shearson Lehman Brothers Inc. "The nervousness in the Mideast is keeping everybody on edge."