In a stinging rebuke to Mayor Bloomberg and his fire commissioner, a Brooklyn federal judge yesterday blasted both for ignoring what he described as pervasive discrimination against nonwhites in the FDNY — and ordered that a special monitor be hired to oversee The Bravest for at least the next decade.

Judge Nicholas Garaufis’ sweeping ruling means a court appointee will oversee all aspects of hiring, training and promotion of city firefighters.

The judge clearly took Bloomberg and his top aides to task for allowing an old-boy system to infect the nation’s largest fire department. He insisted the city “change the perception that the job is available only to white, male candidates.”

Garaufis called the FDNY’s hiring “a shameful blight” on the records of six past mayors — but he aimed his scorn directly at Bloomberg.

“Though the city’s use of discriminatory hiring practices has persisted through numerous changes in city leadership, the evidence adduced in this case gives the court little hope that Mayor Michael R. Bloomberg or any of his senior leadership has any intention of stepping up to the task of ending discrimination at the FDNY,” Garaufis wrote.

“The clear evidence of disparate impact that Mayor Bloomberg and his senior leadership chose to ignore was obvious to anyone who looked,” he added in the 30-page ruling.

“Instead of facing hard facts and asking hard questions about the city’s abysmal track record of hiring black and Hispanic firefighters, the Bloomberg administration dug in and fought back,” Garaufis said.

About 9 percent of the city’s 11,200 uniformed firefighters are minorities.

The judge added that he expected the special monitor to remain in place “for at least 10 years.”

The judge issued his order after ruling in a special trial that the Vulcan Society, which represents black FDNY members, had proven their claims of widespread discrimination.

He ordered both sides to come up with a list of candidates for the special-monitor post.

Bloomberg, obviously stung by the pointed tone and sweeping scope of the order, vowed to appeal. “The judge was not elected to run the city,” he said in response to Garaufis’ order. “You can rest assured we’ll be in court for a long time.

“I think it’s fair to say no previous administration has done more or been more successful in attracting the diversity to the FDNY that we have,” Bloomberg said. “I couldn’t feel more strongly about it.”

Neither could the judge, who’s been presiding over the FDNY hiring case for the past four years.

“The only reason the court today considers how to end the city’s discriminatory hiring practices and eliminate their lasting effects is that a coalition of black New York City firefighters and President George W. Bush’s attorney general, Alberto Gonzalez, decided their only recourse was to sue the City of New York to make it stop,” Garaufis wrote.

The FDNY referred calls for comment to the city Law Department, whose head, Michael Cardozo, vowed to fight the order.

“We strongly disagree with the judge’s opinion and conclusions and are reviewing the draft remedial orders,” Cardozo said.