After Shabbat dinner, a guest asked to speak to Yaakov Smith in private before leaving.

“That was an amazing act you performed for us tonight,” the man said, cryptically. “Take care of yourself.”

Smith managed to stay composed — but in that moment, the ultra-Orthodox Jewish father-of-six’s head began to spin.

“In that moment, I sensed my problem was becoming visible on the outside,” the former yeshiva teacher, now named Yiscah Smith, tells The Post. “I thought I had done a good job of hiding my secret until then.”

Nearly three decades after that fateful encounter at the family home, Smith, 68, is the subject of the upcoming film “I Was Not Born a Mistake,” about her transition from a Chabad man to an observant grandmother of 18.

The documentary, showing at film festivals starting this fall, chronicles Smith’s childhood on Long Island through life as a married scholar in Crown Heights — and her eventual gender transition in 2004.

“I never thought it would be this amazing,” says Smith, now divorced.

Born Jeffrey in July 1951 and given the Hebrew name Yaakov, Smith was the only son of Harold and Joan Smith. The Patchogue, LI, residents worked as a plumbing supplier and a stay-at-home mom.

From the age of 5, their sensitive kid yearned for a female body.

“I woke up every morning expecting to look in the mirror and see a girl, but I didn’t,” says Smith.

Smith, who had two younger sisters, would watch in awe as Joan selected fashionable outfits and applied makeup every day.

“I wanted to be just like my mom. I was very inspired by the way she expressed her femininity. It was really beautiful.”

Smith was picked on at school for “walking, talking and throwing a ball like a girl,” but tried to grin and bear it. “I thought that if I could be more involved with people, I would forget my inner demons.”

It wasn’t until the age of 20, in 1971, that the youth became immersed in the Jewish religion during a trip to Israel. There, Smith remembers, “I encountered my spirituality and soul.”

‘I never thought it would be this amazing.’

By 1974, intellectually minded Smith was immersed in the Chabad Hasidic movement in Brooklyn, marrying an Orthodox woman, Chava. The couple had three sons and three daughters. The family officially “made Aliyah” — the Hebrew term for settling in Israel — in 1985, and received the esteemed blessing of the influential Jewish leader Rabbi Menachem Mendel Schneerson.

“Although I felt peace [in Israel], I also felt troubled, because I didn’t know what to do about the [feeling of disconnect from my] gender,” says Smith, who taught men in their 20s and early 30s at the yeshiva in the Old City. So, “I made a deal with God, with this extreme way of being Jewish . . . I prayed that one day God would help me wake up feeling like a regular man or with the body of a woman.”

As far as members of the synagogue were concerned, the Smiths were the perfect family. Yaakov became chairman in the Chabad house, presiding over Shabbat and entertaining guests from around the globe.

But inside, Smith was in hell.

“I kept my end of the deal, but God didn’t keep his,” she says in the film. “I looked in the mirror with the hat, the beard, with the coat, with the special belt [and thought]: ‘Who am I? Who is that?’ And I started crying.”

The pretense shattered in 1991, after the concerned dinner guest took Smith aside. “He shook me and woke me up,” says Smith. “I slept better that night than [I had in] years.”

Soon afterward, Smith told Chava: I’m gay.

“She was furious,” Smith says in the film. “It was the worst day of my life.”

The rabbis were appalled. One refused to let Smith sit on the couch in his study. “He said, ‘Someone as despicable and disgusting as you, I don’t want sitting on my furniture,’ ” Smith says in the film. Another senior rabbi immediately fired the then-39-year-old teacher from the yeshiva.

“I told them, ‘That’s my livelihood. I need to feed my children.’ The people I used to work with said, ‘This is not our problem,’ ” Smith tells the documentarians.

Before long, the Smiths’ impending divorce became the talk of the Jewish quarter. In 1992, the heartbroken dad returned to New York City alone.

Sitting on a bench in Manhattan’s Bryant Park, Smith flipped through a copy of the LGBT magazine The Advocate. There was an article about someone 10 years older than her who had transitioned. It hit Smith like a thunderclap.

“Until then, I’d thought I was the only person in the world who felt this way,” says Smith. “I thought: ‘Oh, my God, this is the key to my own prison.’ ”

The epiphany launched a decade of exploration for Smith, who did extensive research into gender dysphoria, the condition where a person feels misaligned with their gender, and sex-reassignment surgery. Smith moved to the West Coast and spent several years experimenting — with a relationship with a man, with not keeping kosher — to figure out what a new life might look like.

It wasn’t until 2003, while living in Seattle, that Smith finally felt ready to complete the physical change from man to woman. According to medical rules, candidates for reassignment surgery must live as their desired sex for a year before the procedure. The operation in 2004 was performed at a specialist hospital in Trinidad, Colo., when Smith was 53.

“[The surgery] was what I needed to do in order to be close with God, my soul and the world,” says Smith. “I was able to sleep with a clear conscience and reclaimed my whole life. You could call me a late bloomer.”

Taking the name Jessica — Yiscah in Hebrew — Smith fell in love with a Texan guy. “He said: ‘You have made me feel more like the man I need to feel like than my wives in the past,’ ” says Smith in the film. Although the relationship didn’t last, it was an important landmark for Smith, who told him, “You have completed my transition. You have made me become the woman I always believed I was.”

Meanwhile, Smith slowly won the acceptance of her traditionally minded mother, Joan. The pair began to shop together for trendy clothes. Before passing away in 2015, at the age of 86, Joan told her daughter, “I see something in you I’ve never seen before — peace and serenity.”

Her death brought Yiscah’s religion back into sharp focus. In 2011, she moved back to Jerusalem to further explore her Judaism. She now works as a speaker in the “post-denominational Jewish experience,” offers educational podcasts and often travels back to the US.

Although she has been shunned by some people from her Orthodox past, others have been welcoming.

“I still have problems and make mistakes,” says Smith, who is dating Jewish men and still hopes to meet her “knight in shining armor.”

“But they come from the effort to live with the truth.”

As for her family, she has had no contact with Chava (at Chava’s request, Smith says). But there has been a breakthrough over the past few months with some of their children, from whom Yiscah was estranged.

“My daughter has really come back into my life,” says Smith, who met her 18th grandchild in the hospital in Jerusalem the day after she was born.

“I held the baby in my arms and my daughter told me, ‘This is one of your grandchildren who will know you as one of her grandmothers for her whole life.’ It’s a miracle to me.”