The attack occurred when a roadside bomb struck the convoy of buses carrying prisoners who were being transferred from the prison of Taji, just north of Baghdad, to another prison, the source told Xinhua on condition of anonymity.
Gunmen appeared at the scene after the blast and shot dead all the prisoners and wounded eight policemen, the source said.
It was not immediately clear who killed these prisoners, the source said. An investigation was under way.
On June 23, unidentified gunmen killed 71 detainees when they were being transferred from a prison belonging to a military unit in Babil's provincial capital city Hilla, some 100 km south of Baghdad, to another jail in the town of al-Qasim, some 35 km south of Hilla.