Islamic State fighters seized the city of Baiji and surrounded the sprawling refinery in June during a lightning campaign through northern Iraq.