Iran, one of the largest oil producers, is located along the Strait of Hormuz, through which much of the world's oil is transported. Traders worry that oil supplies could be disrupted if unrest escalates there.

Rumors about a military confrontation spurred panic buying in after-hours trading Tuesday, sending oil prices above $68 in a matter of minutes. Rising tensions between Iran and the West have created a potentially dangerous situation in the Gulf and markets are jumpy.

Prices fell back within a couple hours, although they remained higher than Tuesday's settlement price of $62.93 a barrel. Another possible calming factor was word from Iran's foreign minister that a detained female British sailor would be freed on Wednesday or Thursday.

Iranian state TV aired video of the female captive, along with the 14 other British sailors and marines seized last week, saying the British boats had "trespassed" in Iranian waters.

Oil prices still remain a far cry from last year's record highs, which topped $78 a barrel in July.

Brent crude for May delivery rose $1.18 to finish at $65.78 a barrel on the ICE Futures exchange in London.

Global markets are entering a new phase in which geopolitical instability like this week's tension in Iran will weigh more heavily on oil prices, said Phil Flynn, an analyst at Alaron Trading Corp. in Chicago.

"The risk to be involved with oil has gone up dramatically in just a couple of days," he said. "You wonder if this incident is going to be the first or the last."

Even if Tehran releases Britain's detained female soldier and tensions ease, the sustained demand and lower supplies seen so far this year would buy back any potential price drops, Flynn said.

"It looks like the path of least resistance is up," he said.

The U.S. Energy Department reported that crude oil inventories slipped by 900,000 barrels last week to 328.4 million barrels. Traders had been expecting a gain of 1.1 million barrels, according to analysts polled by Dow Jones Newswires.

Inventories of gasoline and distillate fuel, which include heating oil and diesel fuel, also declined as traders expected. Gasoline supplies fell by 300,000 barrels to 210.2 million barrels and distillates fell by 700,000 barrels to 118.0 million barrels.

Refineries operated at a capacity of 87 percent last week, slightly higher than the previous week.

Gasoline futures fell 1.58 cent to settle at $2.0572 a gallon.

Heating oil futures rose 4.1 cents to settle at $1.8274 a gallon on the Nymex, while natural gas prices climbed 5.5 cents to settle at $7.558 per 1,000 cubic feet.

Still, concerns about the Middle East were likely to remain the main driver of prices. Tehran continues to hold the 15 British sailors it captured on Friday, giving no indications of their whereabouts despite repeated pleas for their release from Britain, the United States and the European Union.

Also, the U.S. kicked off a military training operation in the Persian Gulf on Tuesday that commanders said was meant to send a warning to Iran. The operations are the largest show of U.S. force in the Gulf since the 2003 invasion of Iraq.

"Oil traders are on notice that this thing could blow up at any time," Flynn said.