On the afternoon of Oct. 4, 2011, a backhoe dug into an excavation pit in Elmhurst, Queens, and struck iron. Construction workers assumed they had hit a pipe. But when the claws of the backhoe emerged from the ground, it was dragging a body clothed in a white gown and knee-high socks.

Scott Warnasch, then a New York City Office of Chief Medical Examiner forensic archaeologist, initially viewed the finding as a recent homicide. “It was recorded as a crime scene,” Warnasch, 52, told The Post. “A buried body on an abandoned lot sounds pretty straightforward.”

It turned out to be anything but. The almost perfectly preserved body was actually that of a woman born decades before the Civil War. She had been buried in what was once the grounds of a church founded in 1830 by the first generation of free African-Americans. Now a new documentary, “The Woman in the Iron Coffin,” premiering Wednesday on PBS, provides the woman’s identity.

The Post can reveal that researchers believe her to be Martha Peterson, who worked for a local white man with abolitionist leanings.

The first clue was discovered by Warnasch at the site. “I came across metal fragments that are pretty distinctive,” said Warnasch, now a forensic consultant. “Right away, I knew what they were.”

In fact, there were some 50 or 60 pieces of iron that had been smashed by the backhoe. As Warnasch explains in the documentary, they were from an airtight Fisk iron coffin, made by the now-defunct New York company Fisk & Raymond. A 19th-century phenomenon, it allowed corpses to be sanitarily transported via trains and ships.

A testament to the coffins’ effectiveness, Peterson’s skin was intact to the point that she appeared to have been deceased for only a week. Warnasch noted that “smallpox lesions covered her body.” Initially he was concerned by this: “The body was so well preserved that I would not have been shocked if the smallpox virus had survived.”

Researchers from the Centers for Disease Control and Prevention confirmed that the smallpox had degraded to a nonthreatening level. An autopsy revealed that the disease had infected Peterson’s brain and most likely killed her.

A geochemist pulled chemicals from the woman’s teeth that revealed she had lived for years in the Northeast; data collected from hair confirmed a balanced diet. Investigating bone structure, Warnasch put her age between 25 and 35.

He then went to work on figuring out exactly who she was.

Elmhurst used to be known as Newtown. By the 1850s it was home to a community of free and freed blacks. Assuming that the woman was local to the area, Warnasch turned to an 1850 census report.

“It was the first to list everyone in the population by name, age, sex and race,” he said. “Only 33 individuals fit her criteria.”

One stood out: Martha Peterson. “She would have been 26 in 1850, probably died around 1851 and lived in the household of William Raymond, a partner in the iron-coffin maker Fisk & Raymond,” said Warnasch, adding that its caskets were made between 1848 and 1854. Peterson may even have relatives living in New York City right now, but Warnasch has investigated only a couple of generations beyond her own.

Based partly on the curve of her spine, he believes that she worked for Raymond as a domestic. “She was buried in one of his coffins” — more specifically, one with an upside-down patent mark that probably made it unsellable.

“Finding out who she was, I got goose bumps,” Warnasch recalled. “But Martha’s skull and face [on the left side] had been so damaged by the backhoe that I did not know what she looked like.”

He contacted Joe Mullins, a forensic-imaging specialist who often works with the FBI — creating age-progression renderings that update the photographic images of missing children and fugitives.

Following a CT scan from Peterson’s autopsy, Mullins focused on the right side of Peterson’s skull and face, which were largely intact. “The skull tells where the eyes are. The width of the nose comes from the shape of the nasal aperture; lip thickness is based on teeth enamel,” he said. “I used the skull to tell me the height and angle of her ears.”

With nothing to go on but Peterson’s race, Mullins imparted her with brown eyes and a medium dark skin tone. “I saw this woman come to life on the screen,” he said. “Putting a face to history is remarkable.”

Congregants at the nearby African Methodist Episcopal Church gave Martha a proper burial in 2011. As seen in the show, women from the church scrutinized the photo-realist illustration and instantly related. One excitedly said, “She looks like family.”