A superior court judge has ordered Mayor Martin J. Walsh to release public records detailing the race or ethnicity of individual city employees, a once routine disclosure that the Walsh administration resisted despite pledges of increasing diversity and transparency at City Hall.

In a statement Monday night, Walsh’s administration said it would abide by the order and compile the records for release, although it would not say when.

The ruling by Suffolk Superior Court Judge Mary K. Ames came more than two years after the Globe requested the data under the state’s open records law. The federal government requires the city to collect information on employees’ race and ethnicity, and for years the records had been released publicly.

Advertisement

Walsh took office in 2014 with a pledge to build an administration that reflected Boston’s increasingly diverse population, but the mayor cited privacy and other concerns in refusing to release race or ethnicity data on individuals to the Globe and a Boston city councilor.

In a 10-page ruling dated May 9, Ames wrote that “the purpose of obtaining race and ethnicity data is to prevent discrimination and promote a diverse workforce by ensuring that the city provides equal access to opportunity to all individuals.”

“The court does not find that the Legislature sought to shield from public scrutiny information that is collected for the very purpose of protecting the rights of the public,” Ames wrote.

Walsh’s press secretary, Bonnie McGilpin, said in an e-mail that under the mayor’s leadership the city has “made creating a diverse, inclusive workforce a top priority, hiring the first ever chief diversity officer, appointing the most diverse cabinet ever in Boston, and launching [a web-based] diversity dashboard.”

Leaders in Boston’s African-American community had urged the administration to release the information.

“Mayor Walsh ran on a platform of transparency and diversity,” said Darnell L. Williams, president of the Urban League of Eastern Massachusetts and a member of the mayor’s transition team, who noted that communities of color catapulted Walsh to a narrow victory in 2013. “They should swiftly comply with the judge’s ruling, especially in light of them coming up on another election cycle.”

Advertisement

City Councilor Tito Jackson said that without the data on individuals, it was impossible to assess pay disparities among races and genders.

“We should be moving forward, not backward in transparency,” Jackson said.

The judge’s decision reversed a September 2014 ruling by Secretary of State William F. Galvin’s office, which oversees the state’s public record law. That ruling -- made in Galvin’s office by Supervisor of Records Shawn A. Williams -- said listings of gender and race for individual employees represented personnel information exempt from the public records law.

The Globe sued and in her ruling, Ames declared “the supervisor’s decision was incorrect as a matter of law.” The decision represented the fifth case in which the Globe has successfully challenged a ruling from the secretary of state’s office over the past three years.

In a statement, Galvin’s communications director, Brian S. McNiff, said public record rulings are written narrowly to follow the law, and the judge’s decision regarding race and ethnicity data is now a precedent that will be followed.

Public records advocates hailed the ruling.

“In recent years, the supervisor’s decisions have continued to broaden the personnel records exemption,” said Robert J. Ambrogi, executive director of the Massachusetts Newspaper Publishers Association. “This ruling counters that trend and makes clear that it is not meant to be a blanket exemption from the public records law.”

Advertisement

Attorney Robert A. Bertsche, chair of the media law group at the firm Prince Lobel Tye, said the case was “an example of a broken system.”

“This case really reinforced the need for passage of new, beefed up public records legislation,” said Bertsche, who has done work for the Globe but was not involved in this case.

Walsh has struggled to keep his pledge to introduce a new era of transparency at City Hall. The Globe has two other pending public records lawsuits, including a case filed earlier this month alleging that Walsh’s administration is improperly withholding subpoenas and public documents related to a widespread federal investigation into the activities of local unions.

The mayor campaigned on a promise to build a diverse administration, but a Globe analysis found that his first wave of hires was overwhelmingly white and predominantly male. In a subsequent records request, the Globe sought gender and ethnicity data for all city employees.

But the list included 50 people -- all of whom were black and Latino -- who were not city employees. They had been hired as part of a temporary youth employment program to work in restaurant kitchens and other private companies.

Advertisement

Earlier this month, the administration unveiled a digital diversity dashboard displaying statistics on city workers by race, gender, salary, and tenure.

“It’s wonderful putting up an interactive dashboard and providing [the administration's] interpretation of the data,” said Bertsche, the media law attorney. “But that doesn’t take away the right of a free independent press to get that information for itself and analyze it for itself. That is fundamental to the First Amendment.”