Pro-government Shiite militiamen have killed nearly four dozen Sunni detainees after insurgents tried to storm a jail north east of Baghdad and free them, police say.
The Iraqi military, however, claimed the inmates were killed when the attackers shelled the facility.
The allegation of Shiite killings of Sunnis intensifies the prospect of full-blown sectarian warfare in Iraq after Sunni militants were accused of atrocities in areas they have captured over the past week.
The insurgents were repelled, but the fighting around the jail outside Baqouba was the closest to Baghdad since al Qaida breakaway group the Islamic State of Iraq and the Levant (Isis) began its advance, seizing several key towns and cities in the Sunni heartland in northern Iraq.
There were conflicting details about the fighting in the al-Kattoun district near Baqouba, the capital of Diyala province and one of the bloodiest battlefields of the US-led war. The city is 40 miles north east of the capital.
Three police officers said the police station, which has a small jail, came under attack last night by Islamic militants who tried to free the detainees, mostly suspected Sunni militants.
The officers said Shiite militiamen, who rushed to defend the facility, killed the detainees at close range. A morgue official in Baqouba said many of the dead had bullet wounds to the head and chest.
However, Iraq's chief military spokesman Lieutenant General Qassim al-Moussawi said 52 detainees being held at the station in al-Kattoun died when the Isis attackers shelled it with mortars.
The group is known to be active in Diyala, a volatile province with a mix of Sunnis, Shiites and Kurds, where Shiite militiamen are deployed alongside government forces. Sunni militants have for years targeted security forces and Shiite civilians in the province, which is on the Iranian border.
Nine of the attackers were killed, Gen al-Moussawi said.
Iraq has been in danger of sliding back to the wholesale Shiite-Sunni bloodletting of 2006 and 2007 since Sunni militants seized at least one city and significant parts of the countryside in Anbar province west of Baghdad early this year.
Continuous bombings blamed on Sunni militants in Baghdad and elsewhere, and targeted assassinations of members of both communities, have deepened fears of an outright sectarian war.
During an eight-year presence in Iraq, US forces acted like a buffer between the two Islamic sects, though with limited success. The US military withdrew at the end of 2011, but it is being pulled back due to the latest crisis.
Isis has vowed to march to Baghdad and the Shiite holy cities of Karbala and Najaf in the worst threat to Iraq's stability since US troops left. The three cities are home to some of the most revered Shiite shrines. Isis has also tried to capture the city of Samarra, north of Baghdad, home to another major Shiite shrine.
The push by the Islamic State militants has largely been unchecked as Iraqi troops and police melted away and surrendered in the onslaught on the city of Mosul, and Tikrit, Saddam Hussein's home town.
On Monday, Isis captured the strategically located city of Tal Afar, near the Syrian border, a move that strengthens its plans to carve out a state-like enclave on both sides of the border.
Iraqi military officials said 400 elite troops and volunteers who have joined security forces were flown to an airport outside Tal Afar yesterday, but were immediately pinned down by heavy artillery shelling from the militants.
In Baghdad on Tuesday, a sticky bomb attached to a car in central Baghdad went off, killing three passengers and wounding 11 bystanders, according to police and hospital officials.