Seema, a resident of the northern Indian state of Punjab, mourns with her sons and other relatives after confirmation that her husband had been among dozens of Indian construction workers killed by militants in Iraq. (Narinder Nanu/AFP/Getty Images)

In 2014, 40 Indian construction workers went missing outside the northern Iraqi city of Mosul. The city had fallen to the Islamic State militant group just days before. Relatives said they received panicked calls from some of the workers, begging for help.

Then, for years, nothing.

The Indian government urged relatives not to lose hope.

But this week, Indian officials confirmed that the bodies of 39 of those workers were found in a mass grave near Mosul. Thirty-eight of them have been identified through DNA tests; ID cards and bracelets traditionally worn by Sikh men also were found nearby. Tests on the 39th victim were continuing, but he also is believed to be part of the group. One of the 40 workers, Harjit Masih, had earlier managed to escape his captors.

“With full proof, I can say these 39 are dead,” Sushma Swaraj, India's external affairs minister, told reporters on Tuesday.

The Indian government had long suggested that at least some of the hostages could still be alive. For years, though, that message was contradicted by Masih. He repeatedly told reporters that everyone in the group had been killed. According to Masih, the workers were captured by the Islamic State and held for several days. On the day of the slaughter, he said, the men were taken outside and forced to kneel.

Then, according to Masih's account, the militants began to shoot.

“They were killed in front of my eyes,” he repeated Tuesday from his home in a northern Indian village.

Masih was shot in the thigh but managed to escape to Kurdish-controlled Irbil. Indian officials dispute that account, saying he survived by posing as a Muslim from Bangladesh.

In a statement, Iraq’s government said it had worked with the Indian Embassy to positively identify the remains using DNA samples. Iraq said it would also coordinate with the embassy to return the bodies to India.

The grave may contain other victims, too. The Islamic State, also known as ISIS and Daesh, is accused of executing as many as 500 inmates from a nearby jail in 2014. Dozens of such mass graves have been discovered in parts of Iraq, which had been controlled by the Islamic State. The Iraqi government, hampered by a lack of resources and personnel, has been slow to identify the victims.

In December, the Iraqi government declared victory against the Islamic State, more than three years after the group had overrun and captured ­one-third of the country.

Tamer El-Ghobashy contributed to this report.