If that level were sustained, analysts said the Organization of Petroleum Exporting Countries, whose leading members meet informally later this month, might need to raise production to soften the impact of high energy prices on the global economy.
Oil for June delivery rose as high as $40 in Friday morning trading on the New York Mercantile Exchange, retreating to $39.60, or 23 cents higher than when the day began. The Nymex briefly posted trades as high as $40.05 before discovering a mistake and removing them, one trader said.
The last time the front-month futures contract settled above $40 was on Oct. 11, 1990, when oil was valued at $40.42 per barrel leading up to the Persian Gulf War. In today's dollars, adjusting for inflation, that would be equivalent to $56.83, according to the Energy Department.
Oil has been trading above $30 a barrel since late last year and the pump price of gasoline has been at a record-high, in nominal terms, for weeks.
In the Energy Department's latest survey, the average nationwide price of unleaded gasoline was $1.84 per gallon. That's still less expensive than in 1981 when, in today's dollars, prices approached $3 a gallon.
The latest oil rally was triggered by violence in Saudi Arabia, where gunmen fired on the offices of an oil contractor last weekend, killing five Westerners and a Saudi.
A week earlier, suicide bombers in boats attacked pumping stations at Iraq's Al-Basra Oil Terminal in the Persian Gulf, costing some 350,000 barrels of production.
Together, the events triggered fears among traders that the Middle East oil industry was increasingly vulnerable to attacks and, potentially, supply disruptions.
"A security premium has definitely been growing," said John Kilduff, senior energy analyst at Fimat USA in New York. "It's become quite clear that the oil industry and oil infrastructure are in the crosshairs of the insurgents in Iraq and terrorist groups because it's the lifeline of the global economy."
The violence in Saudi Arabia was particularly troubling, Kilduff said, because the world's top oil producer was "previously viewed as a secure country."
Oil markets have been volatile for more than a year due to political instability in other petroleum-producing nations, including Venezuela and Nigeria.
The rising cost of oil has been a burden to fuel-intensive industries, such as airlines and truckers. Motorists, though, have showed few signs of curbing their consumption. Nationwide gasoline demand averaged 9.1 million barrels per day during April, about 4 percent higher than a year ago.