It was the crazy set-up for a comedy classic — but now it’s a real-life nightmare for this mom.

An upstate woman says she was separated from her newborn baby in the hospital, when — in a scenario straight out of a “Seinfeld” episode — she failed a drug test after eating a poppy seed-covered bagel.

“Everyone keeps telling me about that ‘Seinfeld’ scene, but it’s hard to see the funny side,” Elizabeth Dominguez, 29, said of the TV moment where Elaine Benes tested positive for opium thanks to a seed-studded muffin.

“It’s been an absolute nightmare. I’ve hardly stopped crying.”

Dominguez says she innocently gobbled down a toasted everything bagel with cream cheese from Tim Horton’s in the Buffalo suburb of Tonawanda a few hours before heading to the hospital in nearby Niagra Falls to be induced on May 1.

A few hours later, hospital staff revealed that she’d tested positive for opiates.

“I kept telling them, ‘It’s impossible — I don’t do drugs. I don’t even take Tylenol.’ I started freaking out,” she said.

Baby Carter was born at 3:28 p.m. that day — and hospital staff immediately began monitoring him for signs of opioid withdrawal. They told Dominguez they were obliged to alert Child Protective Services.

“I felt like a terrible mom even though I’d done nothing wrong,” she said.

“Not 24 hours after giving birth CPS was in my hospital room . . . I felt I was guilty until I could prove my innocence.”

CPS officers checked the family home and even went to her two older kids’ schools, leaving them “scared and confused” by a barrage of questions, she claims.

Dominguez was discharged two days after giving birth — but says she was told her son had to stay another night without her for monitoring.

“I felt like a terrible mother leaving him,” she said.

“I didn’t sleep all night. I was just crying the whole time.”

A second, more thorough urine test eventually cleared her, and she was finally able to bring little Carter home.

“Everything came back negative because it was such a small dosage,” she said, with the final report confirming the initial test was from “ingestion of poppy seeds on a bagel.”

Dominguez wishes someone had warned her beforehand.

“Expectant moms are warned not to eat all kinds of things — why don’t they warn about poppy seeds?” she asked.

“All of this could have been so easily prevented.”

She said so many of her friends had pointed out the link to “Seinfeld” that she finally watched the episode.

“I can’t believe stuff like this really happens,” she said.

“I use to love my everything bagels. I’m not sure I could ever stomach one again.”

Reps for Niagara Falls Memorial Medical Center as well as the Office of Children and Family Services declined to comment on her case, citing confidentiality laws.