The survivor of a recent massacre by Islamic militants in northern Iraq has given a graphic, harrowing account of his escape from captivity.

In a video interview with the New York Times, Ali Hussein Kadhim, a 23-year-old Iraqi soldier and Shiite, says he was captured by Islamic State with hundreds of other soldiers in June and held captive in Saddam Hussein's former palace in Tikrit.

Sunni soldiers were allowed to repent, but Kadhim and the other Shiites were "marked for death" and lined up before a firing squad.

“I just pretended to be shot,” he said.

After realizing the bullet passed by his head, Kadhim fell forward into a ditch, where he stayed still for four hours. He eventually made it to a riverbank, where he ate insects and plants for three days alongside a badly injured soldier, who never made it out alive.

“It was three days of hell,” Kadhim said.

He spent the next three weeks in an "underground railroad-style journey through insurgent badlands, relying on sympathetic Sunnis to deliver him to safety," the paper said.

Islamic State claims it killed 1,700 Shiite soldiers during the massacre, which would likely make it the deadliest sectarian killing spree in Iraq's history. Kadhim identified himself in a video of the rampage released by the militant group.

The interview and video report below contains graphic images of part of the Islamic State massacre. Viewer discretion is advised.