Fighters from the Islamic State of Iraq and the Levant (ISIL) group, who launched an offensive on the northern Iraqi town of Kirkuk, have been driven back from the oil-producing town by Kurdish forces.

A senior Kurdish military commander, Brigadier General Shirko Fatih, and at least 25 of his soldiers were killed in the battle on Friday in one of the most aggressive ISIL attacks for months, officials said.

"ISIL fighters took advantage of the fog and they launched their surprise attack, but we managed to defeat them," Mariwan Abdel Khaleg, from the Peshmerga 17th Brigade, told Al Jazeera.

"We are responsible for protecting Iraqi territory, inch by inch."

The casualties near oil-rich Kirkuk were a heavy setback for the Iraqi Kurds, who have been at the forefront of the battle against ISIL, which has captured a third of both Iraq and Syria in a blitz last year.

Home to a mix of Arabs, Kurds and Turkmen, the Kurds want to incorporate Kirkuk into their self-ruled region in Iraq's north, a proposition strongly opposed by Arabs and the Turkmen.

Twin bombings

Attacks elsewhere on Friday killed 27 people, with twin bombs hitting a crowded market in Baghdad and a suicide bomber targeting pro-government Shia militiamen who were manning a checkpoint outside a city north of the Iraqi capital.

In the Baghdad market attack, a bomb first exploded near carts used for selling clothes in the central Bab al-Sharqi area, followed by a second bomb as people rushed to help victims from the first blast.

Police and hospital officials said 19 people were killed and 28 others were wounded.

Also in Baghdad, mortar shells landed on a residential area in the Shula neighbourhood, killing four people and wounding seven others, police and hospital officials said.

Meanwhile, a suicide bomber drove an explosive-laden car into a security checkpoint manned by Shia militias near the city of Samarra, killing four militiamen and wounding 10.

The casualties come as Iraq is facing its worst crisis since the 2011 withdrawal of US troops.

ISIL controls about a third of the country, including the north's biggest city Mosul, as well as large areas of neighbouring Syria.