The city will release years-old ratings for more than 12,000 teachers after the state’s top court declined to consider the UFT’s plea to keep the ratings private.

In August, the state’s second-highest court ruled that the scores are a matter of public interest and should be released, confirming a lower-court judge’s ruling. The union immediately asked the highest court, the Court of Appeals, to hear the case and was rejected for the first time in November. Today’s second rejection means the union is out of options and the city will release the ratings alongside the names of the teachers who received them.

The protracted legal battle began when several city news organizations filed a Freedom of Information Law request to release the city’s Teacher Data Reports, which calculated “value-added” scores for some teachers. The union charged that the scores should stay under wraps because they were rife with errors and statistically unreliable — a charge that an independent analysis supported. But the courts ruled that the ratings are a matter of public interest.

A spokesman for the Department of Education, Matthew Mittenthal, said the FOIL requests would be fulfilled within weeks — but he indicated that the department was not completely happy about it. Ex-Chancellor Joel Klein, who created the reports in 2008, supported their release. But Chancellor Dennis Walcott had expressed concern about seeing teachers’ names and ratings in print.

“After considering litigation about Freedom of Information requests from more than a dozen media outlets, the courts have affirmed that we are obligated to release Teacher Data Reports under the law,” Mittenthal said in a statement. “These reports, which include data from almost two years ago, are just one indicator of teacher effectiveness and do not tell the whole story — but the data is useful to principals in their management and support of teachers, especially those at the top and bottom.”

The department stopped producing the Teacher Data Reports last summer, saying that new evaluations required under a 2010 state law would make them unnecessary. The law requires at least 20 percent of a teacher’s evaluation to be based on the same kind of “value-added” analysis of improvement in student test scores.

The courts’ decision — which upholds the principle that data collected by the state is subject to public scrutiny — would imply that ratings under the forthcoming system would also be subject to FOIL requests.

UFT President Michael Mulgrew quickly condemned the ratings’ release today.

“The Teacher Data Reports are based on bad data and an unproven methodology with a huge margin of error. They are not an accurate reflection of the work of any teacher,” he said in a statement. “Their release would be particularly inappropriate in view of the fact that the Department of Education has already announced that they will be discontinued and replaced with a statewide program.”

GothamSchools was not among the news organizations suing to obtain the ratings and does not plan to publish individual teachers’ ratings when they are released.