LOS ANGELES — An op-ed by Megan Thee Stallion on the need to protect Black women was published Tuesday as rapper Tory Lanez had his first court hearing on felony charges alleging he shot her.

“I was recently the victim of an act of violence by a man,” she wrote in the New York Times, without naming Lanez. The op-ed was published shortly before a judge released him on bail and ordered him to stay away from her.

“After a party, I was shot twice as I walked away from him," she wrote about the attacker. “We were not in a relationship. Truthfully, I was shocked that I ended up in that place.”

In the piece titled, “Why I Speak Up For Black Women,” the hip-hop star writes that “Black women are still constantly disrespected and disregarded in so many areas of life.”

In her first public comments on the matter since Lanez was charged Thursday, she explains why, on July 12, the night she was shot in the feet in the Hollywood Hills, she declined to tell police or otherwise publicize that her injuries were from gunfire.

“My initial silence about what happened was out of fear for myself and my friends,” she writes. “Even as a victim, I have been met with skepticism and judgment. The way people have publicly questioned and debated whether I played a role in my own violent assault proves that my fears about discussing what happened were, unfortunately, warranted.”

Lanez, whose legal name is Daystar Peterson, made his court appearance by phone in Los Angeles on charges of assault with a semiautomatic firearm and carrying a loaded, unregistered firearm in a vehicle. He said only “yes, your honor” to a series of questions from the judge and did not enter a plea. His arraignment was postponed until Nov. 18.

Lanez's bail was set at $190,000, which was promptly posted, and he was ordered to make no contact with Megan Thee Stallion and to surrender any guns he owns.

His attorney Shawn Holley declined comment afterward.

The day after he was charged, Lanez said on Twitter that “the truth will come to the light” and “a charge is not a conviction.”

After teasing on Sept. 24 that he might tell his side of the story on social media later that night, he instead released a new album, “Daystar,” which currently sits at No. 10 on the Billboard album chart.

Prosecutors allege Lanez fired on Megan Thee Stallion, whose legal name is Megan Pete, after she got out of an SUV during an argument. If convicted, he could face a maximum sentence of about 23 years.

In her op-ed, she puts her shooting and its aftermath in the context of larger issues for Black women, “who struggle against stereotypes and are seen as angry or threatening when we try to stand up for ourselves and our sisters.”

“We deserve to be protected as human beings,” she writes. “And we are entitled to our anger about a laundry list of mistreatment and neglect that we suffer.”

Many shared their support and adoration for the piece online Tuesday, with some denouncing those who mocked her column.

Megan Thee Stallion has had a breakout run in the past two years that has put her among the biggest stars in hip-hop. She was nominated for artist of the year at the MTV Video Music Awards, was the musical guest on the season premiere of “Saturday Night Live,” and her guest stint on the Cardi B song “WAP” helped turn the track — and music video — into a huge cultural phenomenon.

___

Follow AP Entertainment Writer Andrew Dalton on Twitter: https://twitter.com/andyjamesdalton.