Militants opened fire on unarmed Iraqi civilians on Tuesday, killing at least eight and wounding three in a town 25 km (15 miles) north of Baghdad, a security source said.
Security forces were searching the area in Tarmiya where the shooting took place, the military said in a statement which did not specify a death toll.
"Security forces stopped this terrorist gang," the military later said in a second statement.
It was not immediately clear how many people were killed, with local news media reports putting the toll at between five and 20. One witness told Reuters 16 people were killed and three were wounded.
Iraq declared victory in December over Islamic State, which had seized control of nearly a third of the country in 2014.
However, the group continues to carry out attacks and bombings in Baghdad and other parts of Iraq.