SAN FRANCISCO (MarketWatch) -- Crude-oil futures ended a dramatic week of trading virtually unchanged on Friday, with prices slumping more than $9 in the first two sessions and then soaring to a new record above $147 a barrel on geopolitical concerns before closing the week about 0.1% lower.

Futures sank as low as $136 on Tuesday amid a rising dollar but leaped right back on speculation that Israel may be nearer to launching an attack on Iran and on worries that supplies in Nigeria and Brazil may be disrupted.

Crude for August delivery closed up $3.43, or 2.4%, at $145.08 on Friday on the New York Mercantile Exchange. It hit an all-time record of $147.27 a barrel in electronic trading in early morning trading.

Prices have jumped $9.03 a barrel over the last two consecutive sessions, almost offsetting a loss of $9.25 in the first two days of the week.

"Most of the current upward pressure is about Iran," said James Williams, an economist at energy research firm WTRG Economics. "Until the rhetoric on both sides [Iran and Israel] is toned down, this will be a major driver in oil price movements."

A rising dollar and concerns that a slowing economy could cut into oil demand pummeled oil prices earlier this week.

In a monthly report released on Tuesday, the Energy Information Administration projected that U.S. petroleum consumption will shrink by 400,000 barrels a day in 2008, nearly 40% more than EIA's June projection of a decline of 290,000 barrels.

The change was "based on prospects for a weak economy and record high crude oil and product prices extending into 2009," the EIA said in the report.

The dollar weakened on Friday, The dollar index DXY, +0.04% , a gauge for tracking the greenback against a basket of other currencies, fell 0.7% to 71.91. See Currencies.

Dollar weakness typically boosts dollar-denominated commodities, such as crude oil and gold, as it makes them less expensive to buyers holding other currencies.

Rounding out Friday's action in Nymex dealings, August reformulated gasoline rose 5.23 cents, or 1.5%, to $3.56 a gallon and August heating oil added 3.92 cents, or 1%, to $4.08 a gallon.

Natural gas for August delivery, however, reversed earlier gains and fell 40 cents, or 3.3%, to $11.90 per million British thermal units.

Crude's surge led a broad gain across most commodities Friday. The Reuters/Jefferies CRB Index CRB, -1.01% , a benchmark barometer gauging the prices of major commodities, rose 0.5% to 461.27.

In the Nymex metals pits, gold futures rallied 2%. See Metal Stocks.

Rising tensions

Iran has said it test-fired a number of missiles in recent days, including a missile that's capable of reaching Israel. Such reports, though questioned by some U.S. military officials, have resonated in Israel.

The Jerusalem Post, citing remarks by Iraqi defense ministry sources, reported that Israeli warplanes have practiced in Iraqi air space, adding to speculation about a potential strike on Iranian targets.

"Everything that we were worried about going into the [July 4] holiday weekend has reemerged," said Phil Flynn, vice president at futures brokerage Alaron Trading in Chicago. "The rhetoric from Iran is heating up. They're shooting off the missiles, and [there is] a lot of provocative statements on both sides."

In addition to the mounting tensions over Iran, analysts said the oil market is weighing the possibility of more violence in Nigeria after the militant Movement for the Emancipation of the Niger Delta, known as MEND, said it will end its two-week cease-fire on Saturday.

"The geopolitical mix relative to oil is precarious, at best, and with the weekend looming no one wants much of an exposure, particularly with potential MEND activity tomorrow," wrote Michael Fitzpatrick, an analyst at MF Global, in a research note.

Iran holds the world's second-largest proved oil reserves and is the fourth-biggest producer. Nigeria ranks fifth among exporters of oil to the U.S., the world's biggest oil consumer.

Strike looms in Brazil

Also contributing to the action in oil prices were reports that oil workers at Petrobras PBR, -2.91% , the Brazilian state-run oil giant, may go out on strike.

The union representing workers at Petrobras platforms in the Campos Basin planned a five-day strike, a union official said Thursday, according to a Dow Jones Newswires report. Workers plan to begin the walkout on Monday, the report said.

The strike would halt production at 42 drilling and production platforms in the Campos Basin, off the coast of Rio de Janeiro and Espirito Santo states, Dow Jones reported.