NEW YORK (Reuters) - Gasoline futures surged 10 percent on Thursday as almost a quarter of U.S. refining capacity remained offline and traders scrambled to reroute millions of barrels of fuel, while oil prices rose nearly 3 percent.

The Valero Houston Refinery is threatened by the swelling waters of the Buffalo Bayou after Hurricane Harvey inundated the Texas Gulf coast with rain, in Houston, Texas, U.S. August 27, 2017. REUTERS/Nick Oxford

U.S. gasoline futures RBc1 have rallied roughly 26 percent from the previous week to a two-year high above $2 a gallon, buoyed by fears of a fuel shortage days ahead of the Labor Day weekend that typically brings a surge in driving. Gasoline was up 21.03 cents, or 11.2 percent, at $2.0950 at 1:53 p.m. (1753 GMT).

Hurricane Harvey, which brought record flooding to the U.S. oil heartland of Texas and killed at least 35 people, has paralysed at least 4.4 million barrels per day (bpd) of refining capacity, according to company reports and Reuters estimates.

The shutdowns led the U.S. government to tap its strategic oil reserves for the first time in five years on Thursday, releasing 500,000 barrels of crude to a working refinery in Louisiana. Traders were also scrambling to redirect fuel to the United States.

U.S. West Texas Intermediate (WTI) crude futures CLc1 recovered some early-week losses, trading $1.24 per barrel higher at $47.20 per barrel at 1309 EDT (1709 GMT). It was still on track to close the month down just under 6 percent, the steepest monthly loss since March.

International benchmark Brent crude LCOc1 was up $1.47 per barrel, or 2.89 percent, at $52.33 a barrel. It had fallen by just over 2 percent in the previous session.

“The market has turned in reverse pretty sharply,” said Gene McGillian, manager of market research at Tradition Energy. “You do have some signs of rebalancing, regardless of Harvey.”

Prices fell on Wednesday despite a drop in U.S. crude stocks, which are typically watched closely by oil investors as a sign of balance. The data showed a 5.39 million barrel drop in commercial crude stocks last week. They are now 14.5 percent below the record levels hit in March. C-STK-T-EIA [S/EIA]

OPEC output also fell this month by 170,000 bpd from a 2017 high, a Reuters survey found, as renewed unrest cut supplies in Libya and other members stepped up compliance with a production-cutting deal

Analysts said the status of U.S. refineries could be a key to oil prices going forward.

“We could see rising U.S. crude inventories in the next couple of weeks until demand from refineries recovers. But by the end of September I expect the situation to be almost back to normal,” said Frank Schallenberger, head of commodity research at LBBW.

Analysts at Goldman Sachs and Stifel said they expected U.S. infrastructure outages to last several months but said it was difficult to estimate the exact damage.

Others saw potential for operational refineries to delay typical September seasonal maintenance to benefit from high prices.

“Refineries outside the affected area may delay maintenance to benefit from high processing margins,” said Commerzbank oil analyst Carsten Fritsch.

“Hence, the negative impact on crude oil demand and oil product supply might be less severe than feared.”

The trend for shrinking oil stocks and expectations for a rise in global oil demand growth meant analysts polled on a monthly basis by Reuters raised their oil price forecasts for the first time in six months. OILPOLL