The police commander who led the effort to arrest Harvey Weinstein has been ousted from his longtime position as the head of the Police Department’s special victims division in a major shake-up that comes as the department’s handling of sex crimes is facing increased scrutiny and criticism.

The chief of detectives announced the change in leadership on Friday afternoon.

The division’s reputation was tarnished when it came to light in court that one of its detectives made serious errors that compromised the sexual-assault investigation of Mr. Weinstein, the movie producer. In addition, a city watchdog agency found in March that the unit had far too few detectives to handle the city’s sexual assault cases.

The decision to transfer the division’s commander, Deputy Chief Michael Osgood, to a new post as head of patrol operations in Staten Island was months in the making. The police commissioner, James P. O’Neill, promised a “top-to-bottom scrub” of the unit back in April after a report by the city’s Department of Investigation found the special victims division was severely understaffed.

Chief Osgood, a highly respected manager within the department, had won praise from advocates in his eight years at the helm of the division. But he had also pushed his superiors hard for more resources, and his warnings over the last four years about the state of the city’s sex crimes unit were made public in the investigation department’s report.