US oil settles at $45.88 a barrel, down $1.74, or 3.65%

A worker checks the valve of an oil pipe at Nahr Bin Umar oil field, north of Basra, Iraq.

Oil prices tumbled lower on Friday but were still set for their first weekly gain in three weeks after Russia and Saudi Arabia agreed to work together to help rebalance the markets and after a surprisingly large drawdown in U.S. crude stocks.

Brent and West Texas Intermediate crude futures were on course to gain about 4 percent this week following two consecutive weeks of declines.

The Brent crude benchmark for November delivery was down $1.97 at $48.02 a barrel as of 2:38 p.m. ET after rising above $50 for the first time in two weeks on Thursday.

NYMEX crude for October delivery was down $1.73 at $45.89, with both contracts pressured by a stronger dollar index amid concerns over the health of the EU economy.

The U.S. oil drillers added seven rigs for the week, marking the 10th week of increase in 11, according to Baker Hughes.

The International Energy Agency has said it expects oil demand to finally exceed supply in the third quarter of 2016, meaning record global crude stockpiles should start falling.

But analysts from Morgan Stanley said in a note on Friday there were risks the market might not rebalance until later.

"Once again, we see an increasing probability for several unexpected bearish developments to come together, which could push off re-balancing (seasonally-adjusted demand exceeding supply) to late 2017, or even 2018," Morgan Stanley said.

Bank of America Merrill Lynch said it saw prices picking up towards the end of the year, with WTI prices reaching $54 per barrel, and any dip in prices would be a buying opportunity.

If OPEC and non-OPEC producers agree to implement measures to limit supply when they meet next month in Algeria, it should help the markets rebalance.

Algeria's oil minister said on Friday two separate agreements could be required between OPEC members and non-OPEC, highlighting the difficulties of clinching such deals.

The oil options market indicates traders are not betting big on OPEC and rival Russia clinching a meaningful deal this month. BAML said it did not expect the OPEC gathering in Algiers to take any decisions.

Iran's steep oil output growth has stalled in the past three months, new data showed, suggesting Tehran might be struggling to fulfill its plans to raise production to new highs.

Oil prices shot up on Thursday after U.S. government data showed the biggest weekly drop in stockpiles since January 1999. Traders said imports fell as ships delayed offloading cargoes in Texas and Louisiana due to Tropical Storm Hermine.