[What you need to know to start the day: Get New York Today in your inbox.]

The top law enforcement official in Elizabeth, one of New Jersey’s largest and most diverse cities, resigned on Tuesday after an inquiry found that he had routinely referred to police officers in his department using racist and sexist slurs.

The official, James Cosgrove, who has led the police force in Elizabeth since 1998, had faced mounting pressure to step aside following an investigation by the Union County prosecutor’s office that began after a lawyer for several police officers filed complaints.

The state’s attorney general, Gurbir S. Grewal, had demanded that Mr. Cosgrove resign.

Mr. Grewal pointed to the prosecutor’s findings, which have not been publicly released, but “concluded that, over the course of many years, Director Cosgrove described his staff using derogatory terms, including racist and misogynistic slurs.” Mr. Grewal also ordered an examination of the culture of the Elizabeth Police Department.

The city’s mayor, J. Christian Bollwage, who had refused to discuss the findings of the two-month investigation, on Tuesday issued a news release announcing that he had accepted Mr. Cosgrove’s resignation. As a political appointee, Mr. Cosgrove could only be removed by the city’s mayor.