“There’s no way that we could condone Anita Alvarez being our state’s attorney for another term,” said Veronica Morris Moore, a leader of a coalition of black community groups called the Bye Anita Campaign. “This does not mean that we believe in Kim Foxx,” the winning challenger.

Critics of law enforcement hope the results send a message to prosecutors, but they do not claim they are part of a trend. In Missouri, the St. Louis County prosecuting attorney, Robert McCulloch, easily won re-election in 2014, days before announcing that a grand jury there had not indicted an officer for killing Michael Brown in Ferguson. In New York, the Staten Island district attorney, Daniel M. Donovan, won election to Congress in 2015, after a grand jury decided not to indict an officer in the death of Eric Garner.

“It’s really hard to gauge whether it’s something that’s going to spread or not,” said Representative Marcia Fudge, Democrat of Ohio, a critic of Mr. McGinty and the Cleveland police. “It always depends on the case. In Cleveland, it was a number of things that came together, kind of a perfect storm.”

Chicago’s mayor, Rahm Emanuel, and the former police superintendent Garry McCarthy have been battered over the McDonald case and other police shootings; Mr. Emanuel has become so unpopular that in the Democratic presidential primary, Bernie Sanders’s campaign worked hard to link the mayor to Hillary Clinton.