U.S. oil prices rose on Friday for the first time in a week as the dollar fell and investors cautiously bought some riskier assets as anxiety eased about Britain's possible exit from the European Union.
But crude futures still posted a weekly loss after daily declines Monday through Thursday.
Brent crude futures were up $2.05, or 4.3 percent, at $49.25 a barrel, after slumping 3.6 percent in the previous session.
U.S. West Texas Intermediate crude futures settled 3.8 percent higher, or $1.77, at $47.98. The contract fell 3.8 percent in the previous session. For the week, WTI settled about 2 percent lower.
Oil services firm Baker Hughes reported its weekly rig count rose by 9 to a total of 337. At this time last year, drillers were operating 631 rigs in U.S. oil fields.
This is the third consecutive weekly increase in the rig count.
The dollar fell 0.5 percent, retreating from a 2-week high on Thursday that had weighed on demand for greenback-denominated oil from the holders of the euro and other currencies.
Some analysts cautioned that with the UK's future in the EU still unknown until a vote next Thursday, oil could come under pressure again.
"It's mainly Brexit at the moment, at least until next Thursday, before people start to look at the more fundamental oil/commodity drivers again," ABN Amro senior energy economist Hans van Cleef said.
Analysts said that investors had closed some short positions after a week of volatile trading, which helped to bring about some correction in oil prices on Friday.
Julian Jessop, chief economist and head of commodities research at Capital Economics, told Reuters Global Oil Forum that a Brexit situation could lead to a sharp oil selloff sending Brent to as low as $40.
He forecast Brent and WTI crude would be around $45 a barrel at the end of 2016 and around $60 at the end of 2017.
Chevron, the second largest U.S. oil company, is soliciting interest in its Burnaby, British Columbia, refinery and gasoline stations, the company told Reuters.
Shell is looking for buyers for its Martinez, California, refinery, two people familiar with the situation told Reuters. Shell declined to comment.