Harry Potter author J.K. Rowling and the team behind the Fantastic Beasts movies are coming under fire from some fans online after defending the casting of Johnny Depp amid earlier allegations of domestic violence levied against him.

"The huge, mutually supportive community that has grown up around Harry Potter is one of the greatest joys of my life. For me personally, the inability to speak openly to fans about this issue has been difficult, frustrating and at times painful," Rowling wrote in a post on her official website Thursday.​

Depp portrays the central role of an evil wizard named Grindelwald in the film series. Depp appeared briefly at the conclusion of Fantastic Beasts and Where to Find Them, but his character is central in the forthcoming sophomore instalment, Fantastic Beasts: The Crimes of Grindelwald

Rowling acknowledged that as Depp was filming his cameo for the first film, the news stories that emerged about Depp and ex-wife Amber Heard's divorce "deeply concerned me and everyone most closely involved in the franchise." 

Johnny Depp-Divorce

Amber Heard and Johnny Depp, seen in January 2016, settled their divorce in August. (Jordan Strauss/Invision/Associated Press)

In her divorce filing, Heard accused Depp of being verbally and physically abusive during their relationship. Depp denied the allegations. Their divorce was settled out of court in August, with Heard pledging to donate the funds to charity. 

"Neither party has made false accusations for financial gain. There was never any intent of physical or emotional harm," the pair said in a statement at the time.

Recasting had been considered

Rowling, who created the Potter spinoff series and wrote the Fantastic Beasts screenplays, acknowledged that the film team had at one point "considered the possibility of recasting" Depp.

"However, the agreements that have been put in place to protect the privacy of two people [Depp and Heard], both of whom have expressed a desire to get on with their lives, must be respected. Based on our understanding of the circumstances, the filmmakers and I are not only comfortable sticking with our original casting, but genuinely happy to have Johnny playing a major character in the movies," she wrote.

"I accept that there will be those who are not satisfied with our choice of actor in the title role."

The Crimes of Grindelwald Cast

Depp, extreme right, is part of a large ensemble cast in the upcoming Fantastic Beasts sequel. (Pottermore/Warner Bros.)

Her defence of Depp comes amid a charged atmosphere in the entertainment world, initially sparked by myriad of allegations of sexual harassment and assault aimed at disgraced producer Harvey Weinstein. This fall, dozens of high-profile men in the worlds of entertainment, media, tech, politics and more have been called out for alleged sexual misconduct.

Anger from fans

Rowling's missive quickly sparked disappointment and anger from a segment of fans online, some of whom have pledged to boycott the upcoming movie.

Warner Bros. also issued a statement on Thursday about the casting decision.

"We are of course aware of reports that surfaced around the end of Johnny Depp's marriage, and take seriously the complexity of the issues involved. This matter has been jointly addressed by both parties, in a statement in which they said 'there was never any intent of physical or emotional harm.' 

"Based on the circumstances and the information available to us, we, along with the filmmakers, continue to support the decision to proceed with Johnny Depp in the role of Grindelwald in this and future films," the studio said.

Fantastic Beasts director David Yates and producer David Heyman also justified the decision to keep Depp on board.

"None of us involved in Fantastic Beasts would ever let our appreciation of talent obscure other, far more important considerations. We recognized the magnitude of the issues raised and understood the strength of feeling expressed. We hoped and strived at all times to be sensitive to both parties. We stand by our decision to have Johnny in the films," the pair said in a statement.