The source said the attack on Dhuluiya, around 70 km (45 miles) from the capital, was carried out before dawn and continued for two hours before the militants were pushed back.
Among the dead in the attack, the largest of its kind in the area, were civilians and Iraqi forces. Most of the casualties were caused by the car bomb, which struck a market, the source said.
Dhuluiya is part of a belt of Sunni Muslim towns north of Baghdad where the hardline Sunni Muslim Islamic State has managed to wrestle some control, often aligning with local militia who distrust the Shi'ite-led government.
Islamic State fighters took advantage of the chaos in Iraq to muscle in and become the dominant force among Sunnis.
US President Barack Obama ordered air strikes in northern Iraq last month as Kurdish-controlled territory fell to the Islamic State and the capital of Iraqi Kurdistan looked in danger. These have since spread to central Iraq.
A tribal source near the Kurdish city of Kirkuk said Iraqi Air Force jets bombed two areas near the town of Hawijah, killing 14 civilians in Islamic State-controlled territory.
Stay updated on the go with The Times of India's mobile apps. Click here to download it for your device.