Mr. Sanders had said Mr. Uygur was “a voice we desperately need in Congress.” But many Democrats condemned the endorsement, citing Mr. Uygur’s history of offensive comments.

Credit...Christian Monterrosa/Sipa, via Associated Press

LOS ANGELES — Can an endorsement be put back in the bottle?

On Thursday, Senator Bernie Sanders of Vermont endorsed Cenk Uygur, a progressive talk show host running for a California congressional seat who has a history of making offensive comments about women, Jews, Muslims and other groups. But he withdrew the endorsement a day later, after facing considerable backlash for his decision, and after Mr. Uygur made an announcement of his own: He was no longer accepting endorsements of any kind.

“Going forward from today I will not accept endorsements, so it means Bernie Sanders has not endorsed me,” Mr. Uygur said, adding that he did not “want to damage” his potential backers.

The backing from Mr. Sanders, a leading candidate for the Democratic presidential nomination, came in what has already proved to be a heated battle in the race to replace former Representative Katie Hill, who stepped down earlier this year.

Mr. Sanders had called Mr. Uygur, the founder and co-host of the online talk show “The Young Turks,” “a voice we desperately need in Congress” in a statement on Thursday.

“I know he will serve ordinary people, not powerful special interests,” Mr. Sanders said then.

But by Friday afternoon, he had reconsidered.

“Our movement is bigger than any one person,” he said. “I hear my grass roots supporters who were frustrated and understand their concerns. Cenk today said he is rejecting all endorsements for his campaign, and I retract my endorsement.”

Mr. Uygur, who lives outside the district, is running against Christy Smith, a state assemblywoman who has represented the area for years. Ms. Smith has received the backing of many prominent Democrats in the state, including the House speaker, Nancy Pelosi. Her campaign has called attention to Mr. Uygur’s long history of crude comments, many of which are being regularly reposted by her supporters.

In 2017, Mr. Uygur was forced out of the group Justice Democrats, a group he co-founded that backs progressive congressional candidates around the country, after his old blog posts objectifying women came to light.

Mr. Uygur’s long history of comments about women included ranking them on a scale of 1 to 10, based on how likely men would be to have them perform oral sex. He also defended a similar ranking by Harvard’s men’s soccer team, which was widely condemned at the time.

Mr. Uygur, a longtime supporter of Mr. Sanders, has also disparaged former President Barack Obama on his show, argued that bestiality should be legal and hosted white supremacist figures, including David Duke. In one clip that circulated on Twitter, Mr. Duke ends an interview by saying, “I am not, what you call a racist,” to which Mr. Uygur replies, “No, of course not.”

Mr. Uygur called the clip a “complete smear” that had been taken out of context from a combative one-hour interview in which he pushed back on Mr. Duke.

He said he had already apologized for and disavowed many of his past statements, and called the criticism he was facing “incredibly unfair, driven by the corporate Democrats and to some extent corporate media.”

Ms. Smith has mostly declined to comment on Mr. Uygur’s past remarks, which have repeatedly resurfaced in local press. But last month, she told The Washington Post: “I’m not sure how to rank what is most damning of his commentary, but the most disqualifying to me was the night of the Saugus High School shooting when he boasted about his fundraising totals while I was with grieving families and students. He is not fit to serve anywhere, least of all a district where he doesn’t even live.”

Several liberal groups in California have condemned Mr. Uygur, and Mark Gonzalez, the chairman of the Los Angeles County Democratic Party, had called for Mr. Sanders to withdraw his endorsement.

“This man has spent decades, including up until recently, attacking women, the LGBTQ community, Jews, Muslims, Asian-Americans and African Americans,” he said in a statement. “His vulgarity, his hate speech and divisive rhetoric have no place in our party.”

Ms. Hill stepped down from the congressional seat in October after nude pictures of her surfaced online. She faced a House ethics investigation into allegations that she had a sexual relationship with a member of her congressional staff, a violation of House rules and which she denies. Ms. Hill said she was the victim of an abusive husband who had engaged in revenge porn by distributing the photos.

The sprawling congressional district north of Los Angeles includes Santa Clarita and Simi Valley, bedroom communities that are popular with people who work in Los Angeles but move for less expensive housing. The district is widely viewed as moderate, but Mr. Uygur said he had no doubt he would win as a liberal.

“Everyone knows they are criticizing me because they think I am too progressive,” he said Friday.

Will Rodriguez-Kennedy, the chairman of California Young Democrats, noted that many progressive groups had already backed Ms. Smith in the race and said he was surprised by the Sanders campaign’s decision to get involved.

“I am almost positive they didn’t check with this local team,” Mr. Rodriguez-Kennedy said. “It’s not usually a good thing to make controversial endorsements. Cenk has a history of racist and homophobic and misogynistic comments that are inconsistent with the Democratic Party.”

At least two Republicans are also vying for the congressional seat: Steve Knight, the former congressman who lost to Ms. Hill in 2018, and George Papadopoulos, a former Trump campaign adviser who was sentenced to prison for lying to the F.B.I.

The primary election will be held on March 3, the same day as the presidential primary in the state. If no candidate receives more than 50 percent of votes, the top two vote-getters — regardless of party — will advance to the November election.