Scarlett Johansson has quit an upcoming movie role as a transgender criminal following an angry backlash against her casting, she revealed in an interview reported widely in US media on Friday.

The actress was to have taken the lead part in “Rub and Tug,” the story of Dante “Tex” Gill, a massage parlor operator and pimp who became a major crime figure in the 1970s and 80s. Born Lois Jean Gill, he identified as male.

“In light of recent ethical questions raised surrounding my casting as Dante Tex Gill, I have decided to respectfully withdraw my participation in the project,” the 33-year-old told Out Magazine.

“Our cultural understanding of transgender people continues to advance, and I’ve learned a lot from the community since making my first statement about my casting and realize it was insensitive.”

When Johansson’s casting was announced, she and the project were berated on social media for not handing someone from the community the opportunity, with trans actresses Trace Lysette and Jamie Clayton leading the charge.

Johansson’s representatives did not immediately respond to a request for comment, but have previously released a statement pointing out that Jeffrey Tambor, Jared Leto and Felicity Huffman have all made successes of transgender roles.

“While I would have loved the opportunity to bring Dante’s story and transition to life, I understand why many feel he should be portrayed by a transgender person, and I am thankful that this casting debate, albeit controversial, has sparked a larger conversation about diversity and representation in film,” Johansson added.

The actress cited figures from GLAAD — formerly the Gay and Lesbian Alliance Against Defamation — showing LGBTQ characters dropped 40 percent in 2017 from the previous year, with no trans characters in major studio releases.

There was no immediate word on the effect of Johansson’s exit on the production schedule for “Rub and Tug.”

Members of the online transgender community were largely supportive, praising the actress for making a stand but highlighting the long path to equality that must still be negotiated.

“Thank you Scarlett Johansson for pulling out of ‘Rub and Tug’… Now the real work begins,” tweeted civil rights activist and media personality Ashlee Marie Preston.

“This has been a long time coming Hollywood. But the trans community is ready if you are.”