Oil prices rose after news of an apparent military coup in Turkey.
Turkey, which straddles Europe and the Middle East, is not a major oil producer, but is an important pipeline area. Oil prices also rise generally during times of instability in the Middle East.
Gunfire was heard and jets were seen flying in the Turkish capital of Ankara on Friday as Prime Minister Binali Yildirim said a group within Turkey's military had attempted to overthrow the government.
Separately, Istanbul's Bosphorus Bridge and Fatih Sultan Mehmet Bridge were both closed by military forces on Friday, local television channels reported, without giving a reason. Istanbul is 320 miles away from Ankara.
John Kilduff, founding partner of Again Capital, told CNBC that the gains in oil are "absolutely" due to the events in Turkey. He said that the apparent "coup on Turkey has people on edge." Kilduff said, however, that the news is "not necessarily bullish for oil."
Earlier oil prices were on track for a second consecutive weekly gain on Friday after data from top energy consumers the United States and China boosted the oil demand outlook.
Also on Friday, data from oilfield services firm Baker Hughes showed U.S. drillers added oil rigs for a sixth week in the last seven. The number of oil rigs operating in U.S. fields rose by 6 to 357, compared to 638 at this time last year.
The increases have prompted analysts to predict the U.S. oil rig count has bottomed and production will start to edge up by early next year.
Brent crude futures were up 18 cents at $47.55 a barrel at 2:38 p.m. ET. It slipped as much as 1.5 percent earlier to a session low of $46.65.
U.S. West Texas Intermediate (WTI) futures settled at $45.95 per barrel, up 27 cents, or 0.59 percent. The intraday low was $45.05.
Brent was on track for a weekly gain of nearly 2 percent and WTI about 1 percent rafter a volatile week.The market saw daily moves of up to 5 percent earlier this week as the market corrected from last week's near 8-percent slump and reacted to bearish U.S. oil inventory data.
Oil prices hit session highs on Friday after data showed U.S. retail sales rose more than expected in June as Americans bought motor vehicles and a variety of other goods, reinforcing views of steady economic growth in the second quarter. Consumer prices also surged for a fourth straight month.
China's economic growth, came in at 6.7 percent in the second quarter versus a year ago.
Crude futures have risen 75 percent from 12-year lows of $27 for Brent and $26 for WTI in the first quarter. But the market has been unable to make a solid advance above $50 since May, on worries demand will remain short of output and supply.
U.S. gasoline stocks and European diesel inventories have risen in recent weeks despite entering the peak seasonal summer demand period as refineries continue to pump out at near maximum levels.
"Inventories are high and we are in the withdrawal season. Things could get worse when we enter late August and September when inventories usually build," said Hamza Khan, head of commodities strategy at Netherlands-based ING Bank, which expects Brent to average $40 in the third and fourth quarters.
Industry monitor Genscape reported on Thursday a 171,511-barrel build at the Cushing, Oklahoma, delivery hub for WTI futures during the week to July 12, traders said.
BNP Paribas analysts say they expect "very little implied global stock change will occur from Q3 2016 until the end of 2017" in oil.
"As such, the inventory overhang built from the start of 2014 will remain largely in place, and thus continues to represent an impediment to any price rally," BNP said.
Some analysts are more optimistic.
Bank of America Merrill Lynch's energy research team maintained its outlook for 2017 oil demand, saying it will grow by 1.2 million barrels per day to bring supply into a deficit. Brent will hit $55 a barrel by end-2016, it forecast.
Concerns about a global glut in crude and refined products had weighed on oil earlier in the session.
Prices partly retraced their early losses after China reported economic growth of 6.7 percent in the second quarter from a year earlier, slightly ahead of market expectations.
China's June refinery throughput was up 3.2 percent from a year earlier at 45.08 million tonnes, or 10.97 million barrels per day (bpd), the highest on a daily basis, data from the National Bureau of Statistics showed on Friday.
At the same time, China's domestic crude oil production during the first six months of 2016 fell 4.6 percent from a year ago to the lowest level since 2010.