The Allas oilfield, 35 km (20 miles) south of Hawija, was one of the main sources of revenue for Islamic State, which in 2014 declared a caliphate in parts of Iraq and Syria.
Iraq declared victory over the hardline Sunni militants in late 2017 after pushing them out of all territory it held in the country. They have since reverted to hit-and-run insurgency tactics aimed at destabilizing the government in Baghdad.
"Elements of the terrorist Daesh gangs attacked two security checkpoints in the Alas oilfields area of Salahuddin province, and an improvised explosive device blew up a vehicle belonging to security forces stationed there, leading to the martyrdom of two of them," the statement said.
Militants also opened fire on the security forces who attempted to evacuate the bodies, injuring three more.
A joint force consisting of regular troops and mostly Iran-backed Shi'ite paramilitary groups known as the Popular Mobilisation Forces is pursuing the attackers, the statement said.