(Adds related content, updates prices, adds additional quote)
Aug 9 (Reuters) - U.S. crude stockpiles fell last week as refineries boosted output to the highest percentage of capacity in 12 years, the Energy Information Administration said on Wednesday, but a surprise increase in gasoline stocks capped gains in oil prices.
Crude inventories fell by 6.5 million barrels in the week to Aug. 4, compared with expectations for a decrease of 2.7 million barrels.
The decline came as refiners boosted overall utilization rates to 96.3 percent of total capacity, the highest since August 2005, according to EIA data. Refiners have been running at high rates due to surprisingly strong distillate demand and heavy demand for U.S. exports.
For the week, refiners processed nearly 17.6 million barrels of crude, the most since the EIA started keeping data in 1982, surpassing a record set in May. Refinery crude runs rose by 166,000 barrels per day.
U.S. crude net imports fell last week by 496,000 barrels per day to 7.1 million bpd. On a four-week moving average basis, imports are down 7 percent from a year ago.
Gasoline stocks, however, rose by 3.4 million barrels, compared with expectations in a Reuters poll for a drop of 1.5 million barrels.
"Today's bullish draw to crude inventories has been somewhat negated by a solid build to gasoline," said Matt Smith, director of commodity research at ClipperData.
Oil prices pared gains as traders cited the rise in gasoline inventories and an increase in production outside of Alaska for the weakness. Overall production slipped by 7,000 barrels a day to 9.423 million bpd, including a 22,000 bpd drop in Alaska.
"The large increase in gasoline stocks despite robust demand and the continued increase in oil production outside Alaska should limit price gains," said Carsten Fritsch, oil analyst at Commerzbank AG in Frankfurt, Germany.
U.S. crude futures were up 18 cents to $49.35 a barrel, off the day's high of $49.65 a barrel, as of 1:04 p.m. EDT (1704 GMT). Brent futures were up 31 cents to $52.45 a barrel, also off the day's highs.
Distillate stockpiles, which include diesel and heating oil, fell by 1.7 million barrels, versus expectations for a drop of 131,000 barrels, the EIA data showed. Overall distillate demand is up more than 13 percent over the last four weeks when compared with a year ago.
Crude stocks at the Cushing, Oklahoma, delivery hub rose by 569,000 barrels, EIA said.
(Reporting by David Gaffen; Additional reporting by Scott DiSavino and Ethan Lou; Editing by Paul Simao and Meredith Mazzilli)