The nation’s largest police department illegally and systematically singled out large numbers of blacks and Hispanics under its controversial stop-and-frisk policy, a federal judge ruled Monday while appointing an independent monitor to oversee major changes, including body cameras on some officers.

Mayor Michael Bloomberg said he would appeal the ruling, which was a stinging rebuke to a policy he and the New York Police Department have defended as a life-saving, crime-fighting tool that helped lead the city to historic crime lows. The legal outcome could affect how and whether other cities employ the tactic.

“The city’s highest officials have turned a blind eye to the evidence that officers are conducting stops in a racially discriminatory manner,” U.S. District Judge Shira Scheindlin wrote in her ruling. “In their zeal to defend a policy that they believe to be effective, they have willfully ignored overwhelming proof that the policy of targeting ‘the right people’ is racially discriminatory.”

Stop-and-frisk has been around for decades in some form, but recorded stops increased dramatically under the Bloomberg administration to an all-time high in 2011 of 684,330, mostly of black and Hispanic men. The lawsuit was filed in 2004 by four men, all minorities, and became a class-action case.

About half the people who are stopped are subject only to questioning. Others have their bag or backpack searched, and sometimes police conduct a full pat-down. Only 10 percent of all stops result in arrest, and a weapon is recovered a small fraction of the time.

Scheindlin noted she was not putting an end to the practice, which is constitutional, but was reforming the way the NYPD implemented its stops.

In her long ruling, she determined at least 200,000 stops were made without reasonable suspicion, the necessary legal benchmark, lower than the standard of probable cause needed to justify an arrest. She said that rank-and-file officers were pressured by superiors to make stops — and that high-ranking police officials ignored mounting evidence that bad stops were being made.

“The city and its highest officials believe that blacks and Hispanics should be stopped at the same rate as their proportion of the local criminal suspect population,” she wrote. “But this reasoning is flawed because the stopped population is overwhelmingly innocent — not criminal.”

She also cited violations of the Fourth Amendment protection against unreasonable search and seizure.

“Far too many people in New York City have been deprived of this basic freedom far too often,” she said. “The NYPD’s practice of making stops that lack individualized reasonable suspicion has been so pervasive and persistent as to become not only a part of the NYPD’s standard operating procedure, but a fact of daily life in some New York City neighborhoods.”

Scheindlin did not give many specifics for how to correct such practices but instead directed the monitor to develop reforms to policies, training, supervision and discipline with input from the communities most affected. She also ordered a pilot program in which officers test body-worn cameras in the one precinct per borough where most stops occurred. The idea came up inadvertently during testimony, but Scheindlin seized on it as a way to provide objective records of the encounters.

Scheindlin appointed Peter L. Zimroth, the city’s former lead attorney and previously a chief assistant district attorney, as the monitor. He did not return a call seeking comment.