In 2016, as federal investigators dug into allegations that Mayor Bill de Blasio traded favors for political donations, a senior official at a city agency at the center of the probe was demoted and given a sharp pay cut.

That official, Geneith Turnbull, has filed a lawsuit against the city, alleging that her demotion was motivated by discrimination, and was meant to punish her for standing up to her supervisors.

Ms. Turnbull was a deputy commissioner at the Department of Citywide Administrative Services until she was demoted in February 2017, in what City Hall said was a reorganization of the agency. The lawsuit, filed this month in Federal District Court in Manhattan, accused the city of demoting Ms. Turnbull in retaliation for repeatedly voicing concerns about a pay raise given to one of her subordinates, who she believed had in some way helped to protect Mr. de Blasio during the federal investigation.

The lawsuit also alleges that her demotion was part of a pattern of discrimination against older, minority employees at the agency. Ms. Turnbull is black.