At least 44 prisoners were killed in an overnight militant assault on a police station in the Iraqi city of Baquba, security and medical officials have said.
Accounts differed as to who was responsible for the killings, with Prime Minister Nuri al-Maliki's security spokesman saying the prisoners were killed by insurgents carrying out the attack.
Other officials said they were killed by security forces as they tried to escape.
Earlier, army and police officers said militants attacked and took control of parts of Baquba but security forces eventually repelled the assault.
The overnight attack took place in the centre of Baquba, the capital of Diyala province, and saw militants temporarily occupying several neighbourhoods.
The city, located 60km 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.
Since 9 June, the militants have overrun all of one province and major parts of three more.
The offensive is led by the Islamic State of Iraq and Syria (ISIS) militants, who are also known as ISIL, and also involves others including supporters of ousted dictator Saddam Hussein.
Security forces performed poorly during the initial assault, in some cases abandoning uniforms and vehicles to flee.
However, they seem to be recovering somewhat from the shock of the onslaught, and have begun to push back.
Mr al-Maliki, meanwhile, has dismissed several senior security force commanders.
Those dismissed included Staff Lieutenant General Mahdi al-Gharawi, the top commander for the northern province of Nineveh, the first to fall in the recent assault.
One other senior officer army officer will face court-martial for desertion, the premier said in a statement read on state television.
ISIS's advance may pose the biggest security crisis to Iraq since the worst of the sectarian bloodshed that followed the US-led invasion to oust Hussein in 2003.
The group's aim is to create an Islamic caliphate encompassing Iraq, Syria and Lebanon.
Militants also attacked a northern Iraqi village inhabited by Shia ethnic Turkmens but were repelled, police said.
They were beaten back from the village of Basheer, 15km south of the city of Kirkuk after an hour of clashes with local militia and police forces.
Iraqi state news channel Iraqiya said that the army had killed two commanders from ISIS today. It did not say where in Iraq.
President Obama to meet Congress leaders
US President Barack Obama will meet tomorrow with the leaders of both houses of Congress to discuss the situation in Iraq.
Mr Obama will meet with Senate Majority Leader Harry Reid, Senate Minority Leader Mitch McConnell, Speaker of the House John Boehner and Democratic Leader Nancy Pelosi at the White House.
The meeting is part of Mr Obama's ongoing consultations with the congressional leadership on foreign policy issues, and will include discussions on the Iraqi situation.
The US discussed the crisis in Iraq with Iran on the sidelines of nuclear talks in Vienna yesterday, US officials said.
State Department deputy spokeswoman Marie Harf confirmed to CNN television that there were "brief discussions".
It is yet to be determined "if we want to keep talking to Iran about Iraq," she added.
However, she acknowledged that Iran and the US had "a shared interest" in ensuring that ISIS do not get "a foothold any more in Iraq".
But she stressed: "No outside country can fix Iraq's problems. We need Iraq's political leaders from across the spectrum to step up."
Aid agency dispatches team
Irish aid agency GOAL has dispatched an emergency response team to northern Iraq.
The team will assess how best the agency can support some of the hundreds of thousands of Iraqis who have been displaced by the recent violence.