By Isabel Coles and Ghazwan Hassan
TUZ KHURMATU, Iraq (Reuters) - Clashes between Kurdish and Shi'ite Turkmen paramilitary forces in northern Iraq killed at least 12 fighters and cut off a key road between Baghdad and the oil city of Kirkuk for most of Sunday before community leaders reached a ceasefire agreement.
Violence in Tuz Khurmatu, 175 km (110 miles) north of the capital, has become a near monthly occurrence between the armed groups - uncomfortable allies against Islamic State since driving the jihadist militants out of towns and villages in the area in 2014.
A small explosion just before midnight near the local headquarters of two rival political parties sparked armed exchanges between the communities that spread to most neighbourhoods and continued into Sunday afternoon, according to security sources.
Fighters launched mortars into densely populated areas and fired rocket-propelled grenades and heavy machine guns at the opposing positions. Shops were closed and streets deserted as plumes of black smoke rose into the sky and bursts of small arms fire pierced the air.
Sources said at least three buildings were burnt down. Kurdish fighters in al-Jumhouri neighbourhood tore down a Shi'ite flag from a militia commander's house and set the building on fire, a Reuters witness said. Separately, a military vehicle was engulfed in flames on a main road.
Seven Shi'ite fighters and five members of the Kurdish peshmerga forces, including two senior commanders, were killed, security and hospital sources said. Twenty-six fighters and at least two civilians, including a child, were also wounded.
The death toll could continue to rise since snipers from both sides had been preventing people from transporting casualties to hospital for most of the day.
A ceasefire was agreed on Sunday evening following high-level delegations from Kurdish and Shi'ite parties met in the district, said Ahmed Abdel Najjar, head of the provincial council in Salahuddin where Tuz Khurmatu is located.
All parties to the conflict were expected to meet in Kirkuk on Tuesday to try to head off a repeat of the violence.
Reinforcements from both sides that had gathered on the outskirts of Tuz Khuramtu remained in place and sporadic gunfire could still be heard inside the district, but the heaviest fighting had abated by sunset.
Prime Minister Haider al-Abadi phoned military commanders earlier in the day "to defuse the crisis and focus efforts against" Islamic State, which faces government forces at a front line 140 km (87 miles) away in Makhmour.
Abadi, who is also facing a political crisis sparked by an attempt to replace his cabinet with technocrat ministers, said in a statement he had directed the joint operations command to take "all necessary military measures to control the situation".
The tensions in Tuz Khurmatu risk further fragmenting Iraq, a major OPEC oil exporter, as it struggles to contain Islamic State, the gravest security threat since a U.S.-led invasion toppled autocrat Saddam Hussein in 2003.
Efforts to push back the ultra-hardline Sunni insurgents have been complicated by sectarian and ethnic rivalries, including a contest for territory which the Shi'ite-led government in Baghdad claims but the Kurds want as part of their autonomous region in the north of the country.
(Additional reporting by Mustafa Mahmoud in Kirkuk; Writing by Stephen Kalin; Editing by Mark Heinrich and Raissa Kasolowsky)