Twenty-three detainees were killed during a militant attack on an Iraqi convoy transporting them south of Baghdad on Monday morning, officials said.
Seven gunmen also died in the ensuing clashes, according to a police captain and a doctor at a hospital in the town of Hashimiyah, in Babil province. It was not immediately clear how the detainees died.
It is the second instance of a large number of detainees being killed since the start of a militant offensive on June 9 that has overrun large areas of five different provinces.
At least 44 prisoners were killed during a militant assault on a prison in the city of Baquba last week.
Accounts differed as to who was responsible for the Baquba killings, with Prime Minister Nuri al-Maliki's security spokesman saying the prisoners were killed by insurgents carrying out the attack, and other officials saying they were killed by security forces as they tried to escape.