To the world, he was Jeffrey Smith, an ultra-Orthodox Jew and spiritual leader teaching the Torah to hundreds of students in Jerusalem’s Hasidic community. But inside, Smith was keeping a secret.

“Since I was 5 years old, I really thought I was a girl,” Smith, 63, told The Post in an interview last week from Israel, where she has been living for the past two years — as an Orthodox Jewish woman — following sex-reassignment surgery.

As a boy growing up in Patchogue, LI, Smith knew early on that something was amiss. But there was no Internet to tell her what being transgender was all about.

Whatever it was, Smith instinctively knew to keep quiet about it.

“How does a 5-year-old in 1956 tell his mother he’s really a girl?” she said.

At Patchogue HS on Long Island, Smith dated women, but relationships were short-lived. “I loved ­being with them, going to movies, but I always felt like I had to do more — and it didn’t feel right,” she said.

Smith later attended George Washington University and, while pursuing a master’s degree at the Jewish Theological Seminary in 1974, embraced the Chabad-Lubavitch branch of Judaism.

“I was drawn to the part about my soul and not about my body so much,” said Smith, who was born Jewish but not raised religiously.

She soon took on the outward appearance of orthodoxy — flowing beard and dark suits.

“It’s one thing that I have to look like a guy — that was bad enough. But now I have to look like a ­Hasidic man,” she recalled. “I felt I traded my soul to get a soul.”

And she acted like a man, too — marrying in 1973.

“When I saw [my wife] coming to the chuppah [the Jewish wedding canopy] all I wanted to do was run . . . Especially because I felt that I should have been in the wedding gown,” she said.

Smith wanted to make her marriage work — starting a big family might fix her, she thought. The couple had three boys and three girls.

“I kept thinking, maybe these feelings would go away — but of course that never happened.”

Smith declined to discuss her current relationship with the children or her ex-wife, whom she divorced after nearly 18 years in 1991. She’s still close to her parents, but family matters, she said, “are difficult . . . strained.”

The break-up put a scarlet letter on Smith’s talis — the Chabad educational center did not want a ­divorcée teaching there anymore.

She left Judaism entirely for a few years, moved to the West Coast, worked at a Starbucks and dated men for the first time, at first as a man and later dressed as a woman. At age 50 she committed to taking the plunge.

Starting in 2001, she lived as a woman for a year, began hormone-replacement therapy and legally changed her first name to Jessica, in Hebrew, Yiscah, which means “to see.”

Surgery in 2005, she said, was a natural conclusion. “I wanted to get it over with already just to be right with my body.”

Smith, who is single, has written a memoir, “Forty Years in the Wilderness: My Journey to Authentic Living.” She moved back to Israel in 2013.

She’s no longer part of the same Chabad-Lubavitch community, but still teaches classes, attends synagogue and prays at the Western Wall — finally at peace in the women’s section.

“I never thought it would be this good,” she said.