Bombs killed at least 20 people at a cafe in Muqdadiya on Monday.
Militiamen then went on what was described as a rampage. Several local Sunnis were killed, and Sunni-owned shops and homes were destroyed.
The jihadist group Islamic State (IS), which frequently targets Iraqi Shia, said it was behind the cafe blasts.
IS militants also attacked a shopping centre in a predominantly Shia eastern district of the capital Baghdad on Monday evening, killing at least 18 people.
Speaking at the shopping centre on Tuesday, Iraq's Prime Minister, Haider al-Abadi, vowed to keep up the drive to expel IS from the country.
Mr Abbadi said the attacks were a "desperate attempt" by the group to compensate for setbacks it had suffered on the battlefield, notably recently at Ramadi, the capital of Anbar province, west of Baghdad.
But the bombings are inflaming sectarian tensions in sensitive mixed areas, says the BBC's Jim Muir in Baghdad.
The double bombing at the Muqdadiya cafe killed at least 20 people, most of them Shia militiamen from the paramilitary Popular Mobilisation forces which are battling IS in western and northern Iraq. A senior member of the Iranian-backed Badr Brigades was reportedly among the victims.
A security source in nearby Baquba, the capital of Diyala province, told the BBC that Shia militiamen had later gone on a rampage against Sunnis in Muqdadiya, summarily killing at least three men from the central al-Asiri district.
They also blew up seven houses in al-Asiri and set fire to 36 shops in the main market and six Sunni mosques across the town, the sources added.
A senior member of the Popular Mobilisation told the BBC: "We strongly condemn such acts if they occurred, because they reinforce the sectarian divide between the sons of the same country, which we reject completely.
"We will punish the perpetrators of such acts."
Shia militias in Iraq have been accused of kidnapping and killing scores of Sunni civilians since IS seized control of large swathes of Iraq in June 2014.
In a separate development on Tuesday, at least four people were killed in a suicide bomb attack on the convoy of Diyala's police intelligence chief, Brig-Gen Qasim al-Anbuki, security sources said. The general himself was seriously wounded.
Shia Muslim militiamen in eastern Iraq have carried out reprisal attacks against Sunni Muslims after a double bombing, security sources say.