"Harry Potter" author J.K. Rowling revealed in a new essay why she decided to speak out for women's rights despite facing pressure to stay silent on the controversial issue of gender identity.

"By the standards of my world, I was a heretic," Rowling said about the moment she began to believe that the transgender movement was "dangerous" and "profoundly misogynistic." "However, I kept my thoughts to myself in public, because people around me, including some I love, were begging me not to speak."

"So I watched from the sidelines as women with everything to lose rallied, in Scotland and across the UK, to defend their rights. My guilt that I wasn’t standing with them was with me daily, like a chronic pain," she confessed in a new book extract published by the UK's The Times on Wednesday.

Rowling said that she was moved to stand up after witnessing how freedom of speech became under attack when it came to this issue in the United Kingdom.

‘HARRY POTTER’ STAR DANIEL RADCLIFFE ‘REALLY SAD’ OVER JK ROWLING'S STAND AGAINST TRANS AGENDA

J.K. Rowling at a premiere

"Harry Potter" author J.K. Rowling revealed what events led her to speak out for women's rights in a new essay. (Dia Dipasupil/Getty Images)

Her outspokenness to defend women, who were being punished over their views baffled some of her professional colleagues, Rowling claimed.

"People who’d worked with me rushed to distance themselves from me or to add their public condemnation of my blasphemous views," she said. Critical colleagues couldn't understand why she would willingly speak out against the "safe, generally approved position" on gender identity.

"The thing is, those appalled by my position often fail to grasp how truly despicable I find theirs. I’ve watched ‘no debate’ become the slogan of those who once posed as defenders of free speech," Rowling wrote of her critics. "I’ve witnessed supposedly progressive men arguing that women don’t exist as an observable biological class and don’t deserve biology-based rights. I’ve listened as certain female celebrities insist that there isn’t the slightest risk to women and girls in allowing any man who self-identifies as a woman to enter single-sex spaces reserved for women, including changing rooms, bathrooms or rape shelters."

Since speaking out in December 2019, the famous author has faced intense backlash.

Rowling said she's faced death and rape threats. Stars from the "Harry Potter" film series have publicly criticized her and a transgender broadcaster recently reported her for a hate crime.

JK Rowling at a Six Nations match

J. K. Rowling said she's faced death and rape threats over her opposition to transgender ideology. (Andrew Milligan/PA Images via Getty Images)

Rowling said these attacks have been "frightening" at times, but worth it, because she views the gender issue as "the greatest assault" of her lifetime on women's rights. 

"Nobody who’s been through an online monstering or a tsunami of death and rape threats will claim it’s fun, and I’m not going to pretend it’s anything other than disturbing and frightening, but I had a good idea of what was coming because I’d seen the same thing happen to other women, many of whom were risking careers and, sometimes, their physical safety," she wrote. "Very few high-profile women — with honourable exceptions, especially in sport, Martina Navratilova and Sharron Davies foremost among them — seemed prepared to stand up and give these women cover and support. I felt it was well past time that I stepped up too."

"Ultimately, I spoke up because I’d have felt ashamed for the rest of my days if I hadn’t. If I feel any regret at all, it’s that I didn’t speak far sooner," she concluded.

CLICK HERE TO GET THE FOX NEWS APP

Last October, Rowling confessed she felt so strongly about the gender issue that she would "happily" spend time in jail if her government made it a crime to "misgender" a transgender person.

"I'll happily do two years if the alternative is compelled speech and forced denial of the reality and importance of sex," Rowling posted on X after one user told her that under the Labour Party, that could mean two years in jail. "Bring on the court case, I say. It'll be more fun than I've ever had on a red carpet."

Fox News' Kendall Tietz contributed to this report.