BAGHDAD — Gunmen in two speeding cars opened fire on civilians near a town north of Baghdad, killing at least eight people and wounding 13, Iraqi officials said Wednesday. Eyewitnesses reported seeing the attackers displaying the black flag of the Islamic State group.

According to two police officials, the attack happened late Tuesday in a busy commercial area near the city of Tarmiyah, about 50 kilometers (30 miles) north of the Iraqi capital.

No one immediately claimed responsibility for the assault but with the IS flag seen at the scene, it only underscores the Sunni militant group's ability to still launch significant attacks, including in urban areas.

Iraq is heading into parliamentary elections on May 12 — the first balloting since the government declared IS defeated in Iraq earlier this year.

Among the casualties in Tarmiyah were workers who were putting up election campaign posters for candidates running for parliament, police officials said. The officials and eyewitnesses spoke on condition of anonymity because they were not authorized to talk to the media.

Last month, IS warned that anyone who runs for a seat or votes in the election will be considered an infidel, saying it will also attack polling stations.

In an online video, it showed the shooting of what it described "two advocators" — meaning campaigners — for the vote in Tarmiyah. A few days later, the militant group released an audio message accusing Iraq's Shiite-led government of being an agent for Iran.

Nearly 7,000 candidates will vie for 329 seats in the May 12 parliament elections, the fourth since the 2003 U.S.-led invasion.

Some Sunni political parties have expressed concerns that the unstable security situation in some parts of northern and western Iraq, as well as the fact that some 2.3 million people are still uprooted from their homes following the three-year military campaign against IS would affect the turnout in those areas.

In December, Iraq declared victory over IS after driving it from all the territory the militants had seized in the summer of 2014 when they declared their self-styled "caliphate" spanning third of Iraq's territory and neighboring Syria.

However, U.S. and Iraqi officials have said that it is likely to continue launching insurgent-style attacks. In January, IS carried out back-to-back suicide bombings in central Baghdad, killing at least 38 people, and a month later, it ambushed a group of Iraq's Shiite-led paramilitary fighters near Kirkuk, killing at least 27.