The overnight attack took place in the centre of Baquba, capital of Diyala province, and according to the officers, saw militants temporarily occupying several neighbourhoods.
The city, located just 60 kilometres north of Baghdad, is the closest the fighting has come to the capital since a major militant offensive swept down from the north last week.
The offensive, led by jihadists from the Islamic State of Iraq and the Levant group but also involving others including supporters of ousted dictator Saddam Hussein, overran all of one province and major parts of three more since it began late on June 9.