John Burris, a civil rights lawyer in Oakland who was involved in the 2003 settlement and has monitored police overhauls, said the scandals had been bewildering and disheartening because the force appeared to be on the cusp of emerging from more than a decade of court-mandated oversight.

“There’s been a progressive improvement in the city for a few years now,” Mr. Burris said. “There has been optimism. We don’t have the same levels of beatings and beat-downs by police anymore.”

One striking change has been the reduction in searches without probable cause. A decade ago, the police conducted an average of 3,000 a year. Last year, that number was down to 280, Ms. Schaaf said.

As part of the settlement, the city adopted a list of changes, including restrictions and conditions on when officers are allowed to use force. Out of 51 points in the settlement, Mr. Burris said, the police force is close to complying with the final three — racial profiling, the consistency of discipline and the effectiveness of the department in policing itself.

Mr. Burris said the latest problems revealed a culture of collusion and an unwillingness to report wrongdoing.

“It’s disturbing because people knew about it and did nothing,” he said.

Hints of the sex scandal began to filter out last year with the suicide of an officer, Brendan O’Brien, in September. Details of Officer O’Brien’s suicide note, which set off the investigation into sexual misconduct and in which he mentioned the prostitute, were reported in the Bay Area news media, and were highlighted in an exposé in The East Bay Express.