If there is a lesson to be drawn from the sudden departure of First Deputy Commissioner Rafael Piñeiro, the NYPD's highest-ranking Hispanic officer, it is that Commissioner Bill Bratton and no one else runs the department.

Piñeiro told people that he met daily with Bratton, but that the commissioner recently told him in a two-minute conversation he was going in a different direction and needed a different No. 2. Sources say Bratton told Piñeiro he could resign or that Bratton would force him out by late October.

Piñeiro, who did not return a call, is set to leave the department late next month.

People who have spoken with Piñeiro since his sacking described him as "dazed" and "in shock," feeling he was "blindsided."

Contrary to Bratton's recent protestations that the decision to initially retain Piñeiro as first deputy was his alone -- not Mayor Bill de Blasio's -- Piñeiro was foisted on Bratton by the mayor, as was Chief of Department Phil Banks, the NYPD's highest-ranking black officer.

What made Piñeiro's dismissal perplexing is that Bratton had promised a Hispanic police fraternal organization that Piñeiro, who joined the department in 1970, would remain first deputy for Bratton's full term as commissioner.

The proud and courtly Piñeiro -- who during the mayoral campaign, had told de Blasio he possessed "all the credentials" for the commissioner's job -- felt he would then succeed Bratton and become the city's first Hispanic police commissioner.

So what changed? Or to put it another way: What's up with de Blasio?

Despite his promise to inject more diversity at the highest levels of the police department, de Blasio acquiesced to Bratton's decision to dismiss Piñeiro. Last week's events suggest de Blasio and Bratton may have had a timetable agreement on how long Piñeiro would stay and that the mayor's insistence earlier this year on keeping Piñeiro was not about principles but political expediency.

As for Banks, his future looks murky.

He is the department's highest-ranking uniformed officer but is not part of Bratton's inner circle.

Police sources say he struggles running the crime statistics sessions known as CompStat, which established departmental accountability and is a large part of Bratton's legacy.

Police sources say Bratton assigns him projects that are tangential to the day-to-day running of the department and that Banks farms out those assignments to others.

But unlike Piñeiro, who had little political support inside the police department other than the Hispanic officers' groups, Banks is said to be favored by de Blasio's wife, Chirlane McCray, as well as by a loud and influential African-American constituency.

So what will Bratton's next move be? There are a number of ways he can go. He can keep Banks as chief of department and appoint one of the half-dozen Hispanic chiefs to replace Piñeiro. That way Bratton retains a top Hispanic appointment who is his choice, not de Blasio's.

He can also "promote" Banks to replace Piñeiro. While in theory the first deputy is the second-most important position in the NYPD, the job has become largely symbolic. It is ill-defined, with powers and responsibilities as wide or as narrow as the police commissioner determines.

Except for Bratton's appointment of John Timoney in 1995 or Bernard Kerik's appointment of Joe Dunne in 2000 -- each of whom served only a year -- the responsibilities have mostly been narrow.

The ultra-capable George Grasso, who served as first deputy for eight years under Bratton's predecessor, Ray Kelly, had virtually no responsibilities. An indication of his abilities is that after retiring in 2010, he became a judge and is now a key administrator of the city's court system.

In fact, the position of first deputy has devolved into a ceremonial one, a parking spot for some top minority officers and a sop to those seeking "diversity."

On the other hand, as he did with Timoney, Bratton could appoint a strong first deputy, someone in whom he has total confidence. The person who comes closest to that is his former spokesman and now head of counterterrorism, John Miller.

Meanwhile, in his first nine months as commissioner, Bratton has been solidifying his police base, bringing back his insular old gang of 20 years before.

Besides Miller, there is Richard Emery, who heads the Civilian Complaint Review Board and whose son, a recent Princeton graduate, now works for the department.

There is John Linder, Bratton's "re-engineering" consultant from New Mexico, who is again doing some re-engineering.

Louis Anemone, Bratton's former chief of patrol and chief of department, has been sitting in on CompStat sessions.

Most recently Bratton announced the return of his former Chief of Personnel Mike Julian as a consultant, paid $50,000 by the nonprofit Police Foundation.

All that is missing is the late, great Jack Maple, regarded, together with Anemone, as the founder of CompStat. Bratton is ensuring that memories of the Jackster, as Maple called himself, linger. On Tuesday the department will hold a dedication ceremony, renaming the eighth floor room where CompStat sessions are held, as the Jack Maple Room CompStat Center.