Militant attacks on security forces are common in Iraq but the killing of senior commanders is rare.
Major General Ali al-Lami, who commands the Iraqi Federal Police's Fourth Division, and Brigadier General Mohammed Allawi from the same division were killed alongside four members of their security detail, Samara Operations Command sources said.
The generals were leading a reconnaissance mission in the Zor area north of Samara in Salahuddin. Militants opened fire on them as soon as they got there.
Helicopter gunships were firing at the bushes in that area where the militants are hiding, Iraqi army officials said. The defense ministry issued a statement of condolences calling the fallen generals martyrs and heroes.
Four Iraqi police officers were killed and five wounded when Islamic State militants attacked checkpoints in the Allas oilfields area of the northern Salahuddin province late on Monday, police said earlier.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.