UPDATE 6-Oil slips from earlier gains as U.S. gasoline, diesel stocks rise

* Kirkuk-Ceyhan pipeline oil flow falls to 225,000 bpd - source

* Iraq crisis, U.S.-Iran tensions raise supply concerns

* U.S. stocks fall by 5.7 mln barrels, refining rates down - EIA

* OPEC leaning toward nine-month extension of supply cut - sources (Adds EIA data, updates prices, updates bullets, adds quotes, changes lead, recasts throughout; changes dateline, byline)

NEW YORK, Oct 18 (Reuters) - Brent oil prices retreated from three-week highs reached earlier in the day on Wednesday, after a surprising fall-off in U.S. refining runs and an unexpected increase in inventories of gasoline and diesel.

Prices had been higher due to ongoing tensions around oil-rich Iraq and Iran, which raised risk premiums.

International benchmark Brent crude futures fell two cents to $57.86 a barrel as of 11:18 a.m. EDT (1518 GMT). They reached their highest in three weeks earlier in the session at $58.54 a barrel. U.S. West Texas Intermediate (WTI) crude futures were down 11 cents to $51.77 a barrel.

Weekly U.S. crude inventories fell by 5.7 million barrels, the Energy Information Administration said, exceeding expectations.

Refiners throttled down activity as the fall maintenance season got underway, and overall refining runs fell off. In addition, inventories of gasoline and diesel rose, the latter unexpectedly, reviving some concerns about elevated inventories during a time when demand for petroleum products declines.

The dropoff of 4.7 percentage points took refining output to 84.5 percent of capacity, representing the seasonally slowest rate of output since 2011.

"A setback in refinery utilization rates occurred as refiners undergo seasonal maintenance," said Anthony Headrick, energy market analyst at CHS Hedging LLC in Inver Grove Heights, Minnesota. "Builds in refined products and a setback in refined product demand provides weight to the energy complex."

The market has been buoyant of late due to developments in the Middle East, where tensions in northern Iraq threatened to disrupt oil flows through a key pipeline from Iraq to Turkey.

Crude flows through the 600,000 barrel-per-day (bpd) Kurdish pipeline to the Turkish port of Ceyhan have dropped off sharply to around 225,000 bpd, a shipping source told Reuters.

"It remains to be seen whether the Kurds, after withdrawing from the region they claim to be entitled to, will allow crude oil to be transported by pipeline across their territory to the Turkish Mediterranean port of Ceyhan," said analysts at Commerzbank.

The Iraq crisis represents one of two notable Middle Eastern threats to oil supply, along with the ongoing dispute between the U.S. and Iran. U.S. President Donald Trump last week refused to certify Iran's compliance over a nuclear deal, leaving Congress 60 days to decide on further action against Tehran.

During the previous round of sanctions against Iran, some 1 million barrels per day of oil was cut from global markets.

More than one month ahead of OPEC's next official meeting, sources told Reuters its members were leaning toward extending an oil supply cut deal struck with Russia and other producers for a further nine months.

Three OPEC sources said keeping the curbs in place until the end of 2018 was a likely outcome, while a fourth said an extension of six to nine months would be needed to remove all excess oil in storage.

A technical pattern known as a "Golden Cross" was approaching in WTI crude oil contracts on Wednesday, in which the 50-day moving average climbs higher than the 200-day. This is widely seen as a bullish price indicator, and already occurred with Brent futures on Sept. 25.

(Additional reporting by Karolin Schaps in Amsterdam and Henning Gloystein in Singapore; Editing by Chris Reese)