NEW YORK (Reuters) - Oil inched up on Tuesday, lifted by expectations of another crude stockpile drawdown in the United States but price gains were limited amid the reopening of Libya’s largest oil field.

A worker walks past oil pipes at a refinery in Wuhan, Hubei province March 23, 2012. REUTERS/Stringer/File Photo

Prices, however, pared gains in post settlement trade and Brent crude turned negative as the market was disappointed by industry data from the American Petroleum Institute showing a crude stockpile decline largely in line with expectations and a surprise build in gasoline inventories. [API/S]

U.S. crude inventories were expected to have fallen 3.5 million barrels last week, the eighth straight weekly drawdown, and gasoline to have drawn down by over 600,000 barrels, a Reuters poll showed, ahead of weekly data.

Official government inventory data for last week will be released on Wednesday at 10:30 a.m. EDT (1430 GMT). [EIA/S]

Brent crude LCOc1 settled 21 cents, or 0.4 percent, higher at $51.87 a barrel.

Book-squaring ahead of the U.S. crude September contract’s expiry on Tuesday added to price gains, traders and brokers said.

U.S. crude futures for September delivery CLc1CLU7 closed 27 cents, or 0.6 percent, higher at $47.64 while the more active October contract CLc2 ended the session up 30 cents at $47.83.

U.S. gasoline futures RBc1 also led the complex higher for most of the session and settled up 0.4 percent at $1.5908 a gallon as forecasts for heavy rain associated with the remnants of former tropical storm Harvey threatened to cause refinery flooding, traders said.

A tropical depression is expected to form over the southwestern Gulf of Mexico on Wednesday or Thursday.

“Traders of crude oil and gasoline will also have particular interest in the remnants of Tropical Storm Harvey expected to strengthen to Category 1 hurricane status as it crosses the Gulf of Mexico toward a possible Friday landfall on the Texas Coast,” Tim Evans, Citi Futures’ energy futures specialist, said in a note.

“While not a major storm, this will at least serve as a drill for refiners along the coast, in our view.”

Libya’s Sharara oil field was gradually reopening after its latest shutdown, field workers said. Earlier in the day an oil official said it was shut again hours after reopening on Tuesday following a three-day pipeline blockade.

Sharara, which has been pumping up to 280,000 barrels per day (bpd) in recent weeks, has been affected by repeated shutdowns because of protests by armed groups and oil workers.

The Organization of the Petroleum Exporting Countries and non-OPEC producers including Russia have pledged to hold back about 1.8 million barrels per day (bpd) of output between January this year and March 2018 in order to tighten supplies and prop up prices.

Meanwhile, U.S. crude production has broken through 9.5 million bpd, its highest since July 2015. C-OUT-T-EIA

Some analysts say U.S. oil output growth will slow as energy firms cut the number of rigs drilling for oil. RIG-OL-USA-BHI

Still U.S. commercial crude inventories have fallen by almost 13 percent from their March peaks, to 466.5 million barrels as refineries have continually processed record amounts of oil. C-STK-T-EIA

“Another decline in U.S. crude stocks may push prices somewhat higher again, but the upside may be limited - especially if U.S. crude production ticks higher again,” said Hans van Cleef, energy economist at ABN AMRO.

(For a graphic on Brent oil, click tmsnrt.rs/2wCto7h)

(For a graphic, click tmsnrt.rs/2v3MhAs)