The singer, whose full name is Kesha Rose Sebert, filed for a preliminary injunction to allow her to record outside the control of her producer, Dr. Lukasz "Luke" Gottwald.
She alleges Dr. Luke drugged and raped her a decade ago and has committed ongoing abuse.
But Dr. Luke claimed he has invested $60 million in her career and that he agreed to allow her to record without his involvement.
Here's video of Kesha arriving for court:
That was all the judge had to hear. He told Kesha's attorney, Mark Geragos, that "decimates your argument."
"You're asking the court to decimate a contract that was heavily negotiated and typical for the industry," Supreme Court Justice Shirley Kornreichsaid said. "My instinct is to do the commercially reasonable thing."
"She's being given the opportunity to record, she can record," Judge Kornreich said. "She does not have to have any interface at all with Mr. Gottwald in recording or producing."
Dr. Luke had claimed that Kesha was attempting to extort him to get out of her contract with Luke's Kemosabe Records label, housed under Sony. He denies the sexual abuse, and claims she is frustrated by her stalled career.
The singer was welcomed by nearly 100 fans yelling "Free Kesha Now!"
And the social media response from those fans after the ruling was merciless.
the fact that kesha has to choose to either freely make music or avoid the person who abused her is outrageous and degrading #freekesha— bea (@BeaMiller) February 19, 2016
Kesha hugged many of them after she left court.