The officials said the attack took place around sunset on Wednesday in the Mahmoudiya area 30 kilometers south of Baghdad. The area has a Shiite majority.
No one claimed responsibility for the attack but it bore the hallmarks of Sunni militants who have for years targeted security forces and Shiite civilians.
The attack is certain to further stoke sectarian tensions in Iraq, and particularly in Baghdad, as the Shiite-led government struggles to come up with a military response to this month's blitz across the north and west of the country by Sunni militants of the Islamic State of Iraq and the Levant.