Oil prices posted their highest weekly rise since the end of July on higher demand forecasts and the restart of oil-hungry refineries in the United States.
The Organization of the Petroleum Exporting Countries this week forecast higher demand for its oil in 2018 and pointed to signs of a tighter global market, indicating its deal with non-OPEC states to cut output is helping tackle a glut.
That was followed by a report by the International Energy Agency (IEA) saying the glut was shrinking thanks to strong European and U.S. demand, as well as production declines in OPEC and non-OPEC countries.
"This boost to the market is attracting fresh speculative length," said Gene McGillian, director of market research at Tradition Energy in Stamford.
To sustain current high prices, continued strength in demand is needed, he said, noting that a weak fourth quarter in the U.S. could prompt traders to back off of long positions.
U.S. West Texas Intermediate crude ended Friday's session unchanged from the previous session at $49.89 a barrel. The contract posted a 5.1 percent weekly gain, also its strongest in nearly two months.
Benchmark Brent crude was up 3 cents at $55.50 a barrel at 2:03 p.m. ET (1803 GMT) , in a volatile session that saw it stretch from an intraday low of $54.86 to a high of $55.75 a barrel.
The contract was on track for its third straight weekly gain and the highest weekly rise since the end of July.
Data on this week's U.S. oil rig count, an early indicator of future output, showed energy firms last week cut the most oil rigs in a week since January as a 14-month drilling recovery stalled due to weak crude prices.
Drillers cut seven oil rigs in the week to Sept. 15, bringing the total count down to 749, the least since June, General Electric Co's Baker Hughes energy services firm said in its closely followed report.
"Prices have now advanced for the last two weeks off increased demand forecasts from both OPEC and the IEA combined with the near-term demand uplift expected as U.S. oil refineries seek to restart operations post-Hurricane Harvey," analysts at Panmure Gordon said.
Oil investors eyed further impact from increasing crude demand from U.S. oil refineries restarting after hurricane outages.
On Wednesday, 13 of 20 affected U.S. refineries were at or near normal operating rates and another five were restarting or ramping up, according to IHS Markit.
Analysts at HSBC said that despite the U.S. refinery outages, 2017 was set to be an "extremely strong year" for oil demand growth, a key factor underpinning a rise in prices.
"We remain convinced of longer-term upside to crude prices. With the lack of new major project sanctions, we expect conventional non-OPEC supply to start declining post-2018," they said.
They maintained their 2018 and 2019 Brent price assumptions at $65 and $70 a barrel, respectively.
BP Chief Executive Bob Dudley told Reuters in an interview that oil prices were likely to stay between $50 and $60 as major producers kept output restricted.
— CNBC's Tom DiChristopher contributed to this report.