JennyW. Hsu

Oil futures ended sharply higher Friday, with West Texas Intermediate crude prices closing at a three-week high, and posting their largest weekly gain in about four months as traders held out hope for price-stabilization measures by major crude-oil producers.

Comments by Saudi Arabia’s Energy Minister Kahlid al-Falih on Thursday showing the big oil producer’s willingness to help balance the market boosted WTI and Brent crude prices by more than 4% Thursday to their highest levels since the second half of July.

On Friday, September West Texas Intermediate
CLU6, +0.00%
gained $1, or 2.3%, to close at $44.49 a barrel on the New York Mercantile Exchange. Futures prices picked up $2.69, or 6.4%, this week, marking the best weekly gain for crude since the week ended April 8, according to Dow Jones data.

Friday’s settlement for WTI is its highest since July 21.

Brent crude for October delivery
UK:LCOV6
added 93 cents, or 2%, to finish at $46.97 a barrel on London’s ICE Futures exchange, representing its highest finish since July 20. For the week, Brent gained 6.1%—its best weekly gain since April 29.

“Crude-oil prices have stormed back to life over the past couple of weeks, albeit in a volatile manner,” said Fawad Razaqzada, chief technical analyst at Forex.com, in a note.

“The latest trigger behind the rally has been attributed in the media to comments from Saudi Arabia’s energy minister” who said Thursday that this country, the biggest producer among members of the Organization of the Petroleum Exporting Countries, “could participate in coordinated action to help balance the crude-oil market,” said Razaqzada.

However, he expressed uncertainty over whether the comments were the main reason for the price rally. “Similar promises were made earlier this year and no action taken.”

Still, the drop in WTI prices from the year’s high above $51 a barrel in early June wasn't likely justified, he said. Given that, “short-covering seems to be a logical explanation for the oil-price rally.”

Earlier this week, OPEC announced that the 14-member bloc will meet on the sidelines of an energy conference next month in Algeria, reviving the idea of a coordinated production cap, after the cartel failed to reach an agreement at a meeting in April.

“Buying continues to come from investment traders” and futures spreads have seen their contango weaken slightly this week,” said Darin Newsom, DTN senior analyst. Contango occurs when the price of later futures contracts is higher than the near-term delivery price, which implies market expectations that prices will rise.

Newsom attributed the buying to expectations that OPEC may once again try to freeze production, but also added: “What sane person really believes that?”

Saudi Arabia is pumping record amounts of oil—10.67 million barrels a day in July—causing some analysts to cast doubts over the kingdom’s sincerity.

“This doesn’t look like a country that is giving up its fight for market share,” said Tim Evans, a Citi Futures analyst.

The Saudis have been wary of output from non-OPEC oil producers such as the U.S. Data from Baker Hughes
US:BHI
Friday showed that the number of active U.S. oil-drilling rigs rose for a seventh straight week, offering a hint on the outlook for production.

Despite the ramp-up in production by OPEC, global output growth is seen lagging behind demand, thanks to the dwindling output from non-OPEC players and robust demand, the International Energy Agency said Thursday.

It forecasts non-OPEC production to fall by 900,000 barrels this year, before rebounding by 300,000 barrels a day in 2017. The Paris-based agency, however, gave a grimmer outlook on demand, estimating global oil-demand growth to slow to 1.2 million barrels a day in 2017 from 1.4 million barrels forecast for this year.

Back on Nymex, prices for petroleum products saw mixed performance for the week. September gasoline
US:RBU6
gained .92 cent, or 0.7%, to settle at $1.3709 a gallon. Gasoline futures registered a 0.4% weekly loss, while September heating oil
US:HOU6
added 2.4 cents, or 1.7%, to settle at $1.4086 a gallon, finishing 7% higher on the week, and marking its largest weekly advance since March 4.

September natural gas
US:NGU16
settled at $2.5860 per million British thermal units, adding 3.5 cents, or 1.4%. For the week, it ended off roughly 6.7%.

--Sarah McFarlane and Mark DeCambre contributed to this article.

Providing critical information for the U.S. trading day. Subscribe to MarketWatch's free Need to Know newsletter. Sign up here.

Intraday Data provided by SIX Financial Information and subject to terms of use. Historical and current end-of-day data provided by SIX Financial Information. All quotes are in local exchange time. Real-time last sale data for U.S. stock quotes reflect trades reported through Nasdaq only. Intraday data delayed at least 15 minutes or per exchange requirements.