By Jesse North

Pop star Troye Sivan is returning to acting with the highly anticipated — and star-studded — film “Boy Erased,” an emotionally charged drama that takes on the controversial practice of “gay conversion therapy.”

The film is based on Garrard Conley’s 2016 memoir of the same name. The story follows its main character, Jared, to a conversion therapy program where young men and women — including Sivan’s character, Gary — are forced to publicly confess their perceived impure thoughts and deviant acts while wearing drab uniforms reminiscent of prison garb. In one particularly haunting scene, a boy is repeatedly hit with a Bible in an effort to literally beat his homosexuality out of him.

The world portrayed in the film, however, could not be further from the one in which Sivan lives in real life. The confident, 23-year-old entertainer represents a new generation of gay male pop star — one that never had to “come out” while famous, and as a result has been accepted since the beginning.

Prior to signing a record deal, appearing on the cover of Rolling Stone, performing on “Saturday Night Live” and selling out Radio City Music Hall, the internet-born star publicly came out on his own YouTube channel in 2013. The video has been viewed over 8 million times.

Sivan’s flashy stage persona makes it jarring to see him as the quiet, inhibited Gary in “Boy Erased,” which hits theaters on Nov. 2 (“Boy Erased” is being released by Focus Features, which, like NBC News, is part of Comcast/NBCUniversal). The film was written and directed by Joel Edgerton and, along with Sivan, stars Oscar-nominee Lucas Hedges as Jared and Oscar winners Nicole Kidman and Russell Crowe as Jared’s concerned parents, who sent their son to so-called gay conversion therapy.

Sivan said filming “Boy Erased” was an emotional experience for him that “definitely struck a chord.”

“I kept remembering how vulnerable I was at that time in my life, when I was first coming to terms with myself and coming out to my parents,” Sivan told NBC News. “Had I not been lucky enough to have the kind of family I had that was so supportive, I don't know where I'd be today, or who I would be today, or if I'd be here today.”

Troye Sivan performs on Today on May 28, 2018.
Troye Sivan performs on Today on May 28, 2018.Nathan Congleton / TODAY

Conversion therapy is an attempt to change a person’s sexual orientation or gender identity. It has been discredited by medical and mental-health associations, including the American Medical Association, the American Psychological Association, and the American Academy of Pediatrics. Fourteen states and Washington, D.C., have laws banning the practice for minors, according to LGBTQ think thank Movement Advancement Project.

“There's a really tangible result that we're all trying to achieve with this movie,” Sivan said, “which is first and foremost to start conversations and then hopefully end up where there's 50 laws in 50 states that prevent youth from going to conversion therapy.”

According to the Williams Institute at UCLA School of Law, approximately 700,000 lesbian, gay, bisexual and transgender adults have undergone conversion therapy at some point in their lives, including about 350,000 who received this treatment as adolescents.

Sivan, with his 9 million Instagram followers, said he isn’t aiming to talk to his rabid fanbase with “Boy Erased.”

“With my fans, it’s sort of preaching to the choir. They are all on the same page as I am about this kind of thing,” he explained. “The people that I'm really trying to communicate with [in] this film are parents and people who would disagree with me.”

The stark contrast between the world of “Boy Erased” and his own life was not lost on Sivan while filming.

“The craziest thing for me was I was about 70 percent done with [my album “Bloom”] when I went to go shoot this movie. I put everything on pause and completely immersed myself in the film,” he said. “Then I got to come back to my real life, which I now realize couldn't be any further from the film and the story that we're telling. I just felt so lucky that at the end of the day, I got to go home and keep making my gay album.”

His so-called gay album — which includes a track The New York Times described as a "coded anal sex anthem" — debuted at No. 4 on the Billboard 200 chart, marking Sivan’s best album sales to date and his fourth top 10 hit . It also features the folksy breakup tune “The Good Side,” a song that director Edgerton chose to open the film.

Image: Lucas Hedges, Joel Edgerton, Troye Sivan, Nicole Kidman
Lucas Hedges, from left, Joel Edgerton, Troye Sivan and Nicole Kidman arrive at the Los Angeles premiere of "Boy Erased" on Oct. 29, 2018, at the Directors Guild of America.Jordan Strauss / Invision/AP

When Sivan was cast, he immediately offered Edgerton his musical talents as well, offering to make any of his published songs available and to write original ones for the film. Sivan said he wrote six songs right off the bat, none of which felt right, until Edgerton shared with him a scene from the middle of the film where Jared, in the midst of grappling with his sexuality, shares a quiet, almost sacred moment with a young man he meets. Sivan’s dreamlike ballad, “Revelation,” co-written with Icelandic musician Jónsi, is the result.

“It's this moment of relief in the film that I was so touched by,” Sivan said. “You get to breathe for the first time as an audience member as you're watching it.”

“Jared has this really sweet, pure, tender moment, and the sky doesn't fall down on him, and the world doesn't stop spinning,” he continued. “ That’s like a revelation for him. We ended up writing the song about that specific moment and how that moment shapes him.”

“Boy Erased” marks Sivan’s return to acting. His most notable past role was playing a young Hugh Jackman — a fellow Aussie — in 2009’s “X-Men Origins: Wolverine.” He makes his big-screen return next to some of Australia’s other acting titans: Kidman, Crowe and Edgerton. For this coincidence, Sivan has a simple explanation: “There actually is an Australian Illuminati, and we organize these things.”

FOLLOW NBC OUT ON TWITTER, FACEBOOK AND INSTAGRAM