Insurgents surrounded Iraq's largest refinery in the northern town of Baiji, police and an engineer inside said.
Sunni militants first moved into Baiji late on Tuesday, closing in on the refinery, but later withdrew to the surrounding villages after reaching a deal with local tribal chiefs.
A witness who lives in a house near the refinery said the militants arrived in more than 50 vehicles.