Pop star Kesha burst into sobs in Manhattan civil court Friday when a judge announced she would have to keep recording with Sony and music producer Dr. Luke — even though the performer says the producer sexually assaulted her.

But Manhattan Supreme Court Justice Shirley Kornreich did say that Kesha would not have to have any contact with Dr. Luke, whose real name is Luke Gottwald.

“She’s being given the opportunity to record, she can record,” Kornreich said.

“She does not have to have any interface at all with Mr. Gottwald in recording or producing,” Kornreich added.

A lawyer for Kesha, whose full name is Kesha Rose Sebert, had argued that the singer’s “been on ice for two years” because she was tied to an exclusive recording contract with Dr. Luke.

“His endgame here is to destroy her,” Kesha’s attorney Mark Geragos said of the producer.

The two are embroiled in two cross-country legal battles, with Kesha suing Dr. Luke in California, saying he raped her and drove her to eating disorders.

He allegedly called her a “fat f–king refrigerator” at one point.

Dr. Luke has said the claims are “blatant extortion.”

He countersued his former star in New York, saying she fabricated the allegations to get out of her contract.

Kesha arrived at the Lower Manhattan court Friday morning in a glamorous white suit with her mother, Pebe Sebert. She was welcomed by nearly 100 fans yelling, “Free Kesha now!”

The social media response from her fans to the judge’s ruling was merciless.

“What the f–k,” said one supporter on Twitter. “#SonySupportsRape,” tweeted another.

This story first appeared in the NY Post.