Survivors and Sunni officials say the massacre took place on Monday in Barwana as soldiers and allied militias wrapped up an operation to expel Islamic State (IS) jihadists from their last urban bastion in Diyala.
Some military officials have already denied the allegations but Prime Minister Haider al-Abadi announced that an inquiry has been opened.
"The prime minister has ordered an investigation into the matter," his spokesman Rafid Jaboori told AFP, without elaborating.
Barwana is a small village located just west of the town of Muqdadiyah. It housed several Sunni families who had fled IS rule over neighbouring villages.
Shiite militiamen entered Barwana on Monday and allegedly selected young men after checking their IDs before lining them up to be shot.
- Hiding in orchards -
"Cars filled with men carrying mostly light weapons entered the village. They gathered all the people in one place, including some children," said Nahda al-Daini, a lawmaker from Diyala.
"They executed 77 of them," she told AFP. "It was Shiite militia forces who carried out this massacre with cover from the security forces."
Ali Juburi, a 27-year-old father of one, fled to Barwana from nearby Hamada village in June, when IS jihadists swept through swathes of Iraq.
He said that when the fighters entered the village, some men were taken to one side.
"They were still checking some names when we heard shooting and women screaming," he told AFP by phone.
"The mukhtar (village chief) went to a house where killings happened. He found 35 bodies in one place and there were about 40 other bodies nearby," he said.
"He came back and told us to leave everything behind and run because they would kill us. So we ran to an orchard, hid and walked. I eventually reached Muqdadiyah at 1:00 am," Juburi said.
Jamal Mohamed, a teacher who has been compiling names of the victims, said he knew of 71 people who had been executed on Monday but added that a few more were still missing.
"There were four boys aged nine to 12 among the victims, but no women nor girls," he said.
Signup to our newsletter and follow us on Facebook and Twitter!
He added that to his knowledge only 12 of the victims had been buried, while the other bodies had been taken by government elite forces to an unknown location.
The teacher said Monday had started well.
- Army denial -
"When an army commander and officials came in the morning, they were greeted with applause. Some women distributed sweets... We just told them we wanted to go back to our villages," he said.
"They left but, later, the militiamen arrived in several vehicles. They had laptops and started listing names," he said.
Several other witnesses AFP spoke to gave slightly different death tolls but largely matching versions of events.
Lieutenant General Abdulamir al-Zaidi, the officer who commanded army operations in the Moqdadiyah area, denied the allegations.
"Not a bullet was shot in Barwana," he told AFP, adding that 70 Iraqi forces were killed and at least twice that number of IS jihadists in the Diyala operation.
He said his men had found evidence that IS fighters had shaved their beards in their retreat in an apparent bid to escape by blending in with local residents.
Ali Juburi and Jamal Mohamed said the alleged executioners had scribbled messages on walls praising Imam Hussein, a revered Shiite saint.
Another message read "Revenge for Speicher", in a reference to the IS massacre of hundreds of young recruits at a base near the northern city of Tikrit on June 12.
Top UN envoy Nickolay Mladenov welcomed the investigation.
"It is the responsibility of the government to ensure that all armed forces are under its control, that rule of law is respected and civilians are protected in all areas of the country, including those areas recently liberated from IS," he said.
The government last year announced a probe into allegations that Shiite militias had gunned down 70 men at the Sunni mosque of Musab bin Omair in August.
The mosque is also in Diyala, an ethnically and religiously mixed province northeast of Baghdad, where Iran-backed Shiite militias have played a key role in the fight against IS.
Rights groups have documented many cases of revenge attacks and abuses by Shiite militias against Sunnis.
The accusations have infuriated Shiite leaders who argue it was the militias, which they prefer to call "Popular Mobilisation" forces, that saved Baghdad and the rest of Iraq from falling to IS.