LOS ANGELES (Reuters) - Scarlett Johansson on Friday pulled out of a movie in which she was cast to play a transgender character following a backlash from some members of the LGBT community who believed the part should have gone to a transgender actor.

Johansson, one of Hollywood's biggest stars, had agreed to take a role in "Rub & Tug" as Dante "Tex" Gill, a real-life American crime kingpin who used his massage parlour as a front for prostitution in the 1970s and 1980s. Gill was born a woman but identified as a man.

It was the second time Johansson, an American of European descent, found herself in the middle of a casting controversy after appearing in 2017's "Ghost in the Shell" in a role originally conceived as a Japanese character.

Johansson, 33, said she had decided to withdraw from "Rub & Tug" for ethical reasons.

"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 realise it was insensitive," the actress said in a statement to the lesbian, gay, bisexual and transgender magazine "Out."

"I understand why many feel he (Gill) 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," she added.

On social media, newspaper editorials and videos, the transgender community had slammed her casting as highlighting the limited opportunities given to transgender actors.

In recent years, straight actor Eddie Redmayne played a transgender woman in "The Danish Girl," Jared Leto won an Oscar for playing a trans woman in "Dallas Buyers Club," and Jeffrey Tambor has won awards for playing a father who transitions to a man in the television series "Transparent."

According to LGBTQ advocacy group GLAAD, none of the 109 movies released by Hollywood's seven biggest studios in 2017 included a transgender character.

GLAAD welcomed Johansson's decision saying on Twitter that "her announcement, together with the transgender voices who spoke out about this film, are game changers for the future of transgender images in Hollywood."

Filming has yet to begin on "Rub & Tug" and no replacement for Johansson was immediately announced.

(Reporting by Jill Serjeant; Editing by Marguerita Choy and Tom Brown)