NEW YORK (Reuters) - Oil prices ended steady on Friday but lower on the week, with U.S. crude notching its first weekly decline in five weeks, as the market weighed rising U.S. drilling and record stockpiles against efforts by major producers to cut output to reduce a global glut.

A gas station attendant pumps fuel into a customer's car at PetroChina's petrol station in Beijing, China, March 21, 2016. REUTERS/Kim Kyung-Hoon

U.S. energy companies added oil rigs for a fifth straight week, Baker Hughes said, extending a nine-month recovery with producers encouraged by buoyant crude prices, which have held mostly over $50 a barrel since late November.

Globally, the Organization of the Petroleum Exporting Countries (OPEC) and other producers, including Russia, agreed to cut output almost 1.8 million barrels per day (bpd) during the first half of 2017.

Estimates suggest compliance by OPEC is around 90 percent, and Reuters reported on Thursday that OPEC could extend the pact or apply deeper cuts from July if global crude inventories fail to drop enough.

“It’s encouraging that it may not be a six-month deal but one of the issues is if you look at OPEC and other members basically reducing their supply and U.S. shale producers profiting from it, that’s going to produce some turmoil,” said Mark Watkins, regional investment manager at U.S. Bank Private Client Group.

“At some point, it’s going to be difficult for that agreement to stay in place when member countries can drill more and make more money.”

Brent futures settled 16 cents, or 0.3 percent, firmer at $55.81 a barrel, while U.S. West Texas Intermediate (WTI) crude settled up 4 cents at $53.40 a barrel.

Book squaring in March WTI ahead of its expiration on Tuesday weighed on prices, traders said. The U.S. market will be closed on Monday for the Presidents Day holiday.

WTI ended the week down 1 percent and Brent fell 2 percent for the week. Oil prices were within an average band of about $1.30 per barrel so far this year, one of the most range-bound periods since the price slump began in mid-2014.

U.S. gasoline futures ended nearly 1 percent lower, with the gasoline crack spread <RBc1-CLc1 >, a key indicator of refining margins, slumping more than 11 percent early in the day to one-year lows.

Rising U.S. output helped boost crude and gasoline inventories to record highs last week, amid faltering demand growth for the motor fuel.

The oil market was also pressured by a second week of gains in the dollar index, which rose on Friday, making greenback-denominated oil more expensive for holders of other currencies.

Hedge funds and other money managers raised their net long U.S. crude futures and options positions in the week to February 14 to a new record high, data from the U.S. Commodity Futures Trading Commission (CFTC) showed on Friday.

The increase in long positions leaves the market vulnerable to a downward correction, analysts have said.