A new prosecutor was appointed to review the case, but the statute of limitations had almost expired and she ran out of time, though she found the hairdresser “extremely credible.”

The demise of the case was a stinging defeat for Ms. Gardner, who ran for circuit attorney in 2016, two years after nearby Ferguson, Mo., erupted in protest over a police killing. The St. Louis police force is mistrusted by many in the African-American community that makes up half the population.

Ms. Gardner grew up in a black neighborhood of St. Louis in a family that owned a funeral home. After law school, she worked as a prosecutor, attended nursing school, and served as a state representative.

She pledged to reduce the incarceration of minor offenders, and declined to prosecute many low-level marijuana cases. She created an “exclusion list” of more than two dozen officers whose credibility had been called into question, saying she would decline cases that relied on those officers. She has brought charges against more than a dozen officers, including one who was involved in a game of Russian roulette that left another officer dead.

After a police officer she prosecuted for murder in the death of a 24-year-old black man was acquitted by a judge, setting off angry protests, Ms. Gardner apologized to the dead man’s family and urged calm. “We cannot let the naysayers and guardians of the status quo let us miss this opportunity to seek real change,” she said.

Her tenure got off to a turbulent start, with grumbling from progressive groups that she was slow to deliver on her agenda. Now supporters say she is facing payback for moves that unnerved the police, and for displeasure within the legal establishment that she drove out some popular longtime employees.

“Almost from the moment she took office, she faced this chorus of people that questioned her competence and organizational and leadership skills in a way that to me has always seemed both gendered and racialized,” said Blake Strode, executive director of ArchCity Defenders, a civil rights group. Many of the power brokers who have attacked Ms. Gardner are white.