NEW YORK — In a highly unusual move, an appeals court Thursday blocked a judge's ruling that would have required changes to New York's controversial stop-and-frisk policy and also removed the judge from the case.

U.S. District Judge Shira Scheindlin had declared the New York City Police Department's stop-and-frisk policy unconstitutional on Aug. 12, and had ordered a court-appointed monitor to oversee a series of changes to the program.

But after New York City appealed that ruling, the U.S. 2nd Circuit Court of Appeals placed a stay on it, in effect halting those changes. In its opinion, the appeals court said Scheindlin "ran afoul" of a code of conduct for judges for a number of reasons, including media appearances that called her impartiality into question.

The ruling comes just days before a New York City mayoral election in which candidate Bill de Blasio, who is leading in the polls by a wide margin, has indicated he would alter the stop-and-frisk program, if not end it completely.

Experts also say De Blasio is likely to drop the city's appeal, which may make this ruling gratuitous.

It is "extremely unusual" for an appeals court to remove a judge from a case, said James Cohen, a professor of law at Fordham University. "It's a real slap in the face for her."

Stop-and-frisk, which permits police to stop people they suspect of wrongdoing and search them, has been a contentious issue in New York. Some leaders argue that it is one of the reasons the city's crime rates have fallen dramatically: 62% between 1995 and 2011, according to FBI statistics. But critics say the policy permits racial profiling.

Thursday's ruling also comes one day after New York Police Department Commissioner Raymond Kelly was heckled off the stage during an appearance at Brown University in Providence, R.I., where students chanted, "No justice, no peace! No racist police!" in a reference to stop-and-frisk.

In the case being appealed, Floyd, et al. vs. City of New York, attorneys for the plaintiffs argued that stop-and-frisk violated the rights of minority New Yorkers to equal protection under the law, with nearly 90% of all people stopped in the program black or Latino. New York City and the NYPD had argued that the majority of people stopped were black and Latino because police patrol more heavily in high-crime areas where minorities live.

The class-action lawsuit began with four men who sued the department in 2004, saying they were targeted by police because of their race. Scheindlin issued her ruling after a 10-week bench trial that included 11 people testifying they had been unfairly stopped.

Mayor Michael R. Bloomberg had blasted her ruling at the time, saying, "This is a very dangerous decision made by a judge who I don't think understands how policing works."

On Thursday, Michael Cardozo, general counsel for the city, issued a statement saying, "In short, the ruling of unconstitutional practices is no longer operative, and that question will now receive a fresh and independent look both by the appeals court and then, if necessary, by a different trial court judge."

In her 198-page August ruling, Scheindlin said that New York's highest officials "willfully ignored overwhelming proof that the policy of targeting 'the right people' is racially discriminatory and therefore violates the United States Constitution." She ordered the Police Department to explore the use of body-worn cameras to document stop-and-frisks, and called for an independent monitor to ensure that the NYPD carried out stop-and-frisks in accordance with the Constitution.

Scheindlin has long been the judge on cases related to racial profiling because of something called the "related-case rule," which sends all "related" cases to one courtroom. Some attorneys have chafed in her courtroom, accusing her of favoring civil rights lawyers.

The appeals court indicated that Scheindlin had improperly used the related-case rule to encourage attorneys to file the Floyd case. In footnotes to its decision, the appeals court said that in a December 2007 hearing on a separate case, Scheindlin told attorneys that if they had proof of inappropriate racial profiling, "Why don't you bring a lawsuit? You can certainly mark it as related." Those lawyers later filed the Floyd case.

The appeals court said that "perhaps she gave too bald an indication of her leanings and was thought to have encouraged the lawsuit," said Ian Weinstein, a law professor at Fordham University.

Thursday's ruling also cited three articles, by the New York Law Journal, the Associated Press and the New Yorker, as proof that Scheindlin had made improper media appearances by responding to criticism of her rulings.

The Center for Constitutional Rights, one of the groups that brought forward the Floyd case, expressed dismay over the appeals court ruling.

"That, unprompted, they should reassign the case from a judge deeply steeped in the issues for the last 14 years, who gave the city every opportunity to defend itself in the course of this litigation, is troubling and unprecedented," a statement from the group said.

New York City's appeal of Scheindlin's ruling will continue in the 2nd Circuit, with oral arguments beginning sometime after March 14. Should any portion of the case need to be sent back to the District Court, another judge will be assigned.

alana.semuels@latimes.com