Gunmen shot dead at least 16 members of a Shi'ite Muslim family before blowing up their two neighboring homes south of the Iraqi capital overnight, police and medics said.
The attack took place in the town of Latifiya, around 40 km (25 miles) from Baghdad, in a volatile area known as the "triangle of death".
It was not immediately clear who carried out the attack but Sunni militants who view Shi'ites as apostastes have been regaining momentum in their insurgency and striking with a ferocity not seen in years.
"We were sitting in our house when some gunmen opened fire at us through the windows," said a teenage girl wearing a red headscarf and dress, seated on the bed of her 6-year-old brother in a hospital ward. Both their heads were bandaged.
"My father stood and moved toward the door. They shot him dead immediately. They shot my sister dead. They were shooting randomly."
Outside the hospital, people thought to be relatives of the victims wept as they waited to receive the bodies of the dead, which included women and children. One woman struck her head in grief, crying "God is Greatest!"
More than two years of civil war in neighboring Syria have aggravated deep-rooted sectarian divisions in Iraq, fraying an uneasy government coalition of Shi'ite, Sunni and ethnic Kurdish factions.
About 800 Iraqis were killed in August, according to the United Nations, with more than a third of the attacks in Baghdad.
The bloodshed, 18 months after U.S. troops withdrew from Iraq, has stirred concerns about a return to the sectarian slaughter of 2006-07, when the monthly death toll sometimes topped 3,000.
Late on Tuesday, a series of car bombs across Baghdad killed nearly 60 people in predominantly Shi'ite districts, police and medics said.
Separately on Wednesday, a suicide bomber attacked a police headquarters in the northern city of Mosul, killing five policemen. A roadside bomb also struck a patrol in Tarmiya, north of Baghdad, killing five soldiers.