The attack began with a car bomb at the entrance of the facility in Taji, about 20km (12 miles) north of the capital.
Several gunmen wearing explosive vests then entered the plant and fought with security forces, the officials say.
IS, which controls large parts of western and northern Iraq, says it carried out the assault.
An Iraqi military spokesman told Reuters news agency that three of the facility's gas tanks had been set alight but that security forces were able to bring the situation under control.
The Sunni Muslim jihadist group has stepped attack in Baghdad recently.
In the worst violence in the city this year, car bombs killed 93 people in a market in a Shia Muslim area of Baghdad on Wednesday.
Divisions among Iraq's political factions has prevented the formation of a new cabinet. The deadlock has raised concerns about the government's ability to fight IS.