Philip Banks, the NYPD’s highest-ranking black officer, abruptly resigned Friday, throwing the police department’s top leadership, at least for now, into disarray.

The decision by Banks comes six weeks after the department’s highest-ranking Hispanic officer, Rafael Piñeiro, was forced to retire by Police Commissioner Bill Bratton.

Banks, who had served as chief of department, the NYPD’s highest-ranking uniformed officer, was to have been “promoted” to first deputy commissioner on Monday, succeeding Piñeiro.

Banks’ sudden decision to step down followed a Friday morning meeting with Bratton, who police sources said had promised Banks he would enlarge his role as first deputy commissioner from that of the ceremonial position it had been under Piñeiro and most other first deputies.

Banks, a 28-year department veteran, had been reluctant to take the first deputy job, fearing he would be marginalized, the sources said.

Both Piñeiro and Banks, who had been appointed chief of department by Bratton’s predecessor Ray Kelly, had been contenders for Bratton’s job as police commissioner. Although Bratton has maintained that retaining both men as top-level appointees was his choice, they had apparently been forced upon him by Mayor Bill de Blasio.

Police sources said Banks, in particular, was the favorite candidate of de Blasio’s wife, Chirlane McCray, who appears to be playing a larger role in city government than previous first ladies.