Kurdish peshmerga forces backed by local police units recaptured three villages near Daquq, around 180 kilometres north of Baghdad, that had been under IS control since June.
Daquq police chief Kawa Gharib said police officers moved across the frontline during the fighting to take down the flag from a position the jihadists had just lost.
"One of them attempted an act of heroism and wanted to remove the black flag but when he yanked it out, he triggered a small improvised explosive device," the officer said.
Abu Mekhlif al-Juburi, a local resident who witnessed the aftermath of the incident, said IS had booby-trapped dozens of the flags floating above its positions in the area.
Also Read
"It started earlier in September when resident of Tel Ali, in the Hawijah area (west of Kirkuk), burned an IS flag," he said.
"The jihadists came back and kidnapped around 50 people from the area and then put up flags everywhere across the region, on every position," Juburi said.
"IS has raised hundreds of flags at its bases, positions and frontlines. Now they booby-trap them to make sure nobody can remove them," he said.
The Daquq police chief said that the use of explosive devices was slowing the advance led by the peshmerga.
"These people booby-trap everything: the roads, the houses and even the flags," he said.