NEW YORK CITY - (AP) New York City Police Commissioner William Bratton is resigning his post atop the nation's largest police force, after a tenure in which he received credit for keeping crime down and navigated tension between police and minority communities.

Mayor Bill de Blasio announced Tuesday that Bratton will retire next month, and that James O'Neill, the department's top chief, will succeed him. Bratton had said last month that he would not remain head of the NYPD past the end of de Blasio's current term in 2017.

"We will never forget or fail to honor the achievements of Bill Bratton," the Democratic mayor said, calling the commissioner's contributions to the city "inestimable and extraordinary."

De Blasio also heralded O'Neill as someone who would lead a push toward neighborhood policing, or trying to build trust and working relationships between police and communities. Under Bratton, the city already has made plans to shift toward the neighborhood policing strategy. O'Neill has been heavily involved in those efforts, and de Blasio said neighborhood policing would be in place in 51 precincts as of this fall.

A Brooklyn native, O'Neill has risen through the NYPD's ranks for over 30 years, starting as a patrolman in the transit system. He has been chief of department, the department's highest uniformed position, since November 2014.

O'Neill "is ready to take this department where it's never been before in terms of a truly deep and consistent bond between police and community," de Blasio said.

Bratton's resume is unmatched in local law enforcement. He began his career as a patrolman in Boston in 1970 and went on to lead law enforcement agencies in Boston, Los Angeles and New York.

His current tenure at the NYPD was his second. In the first one under Mayor Rudolph Giuliani in the early 1990s, he was credited with driving down crime with a widely copied, data-driven, crime-fighting strategy before his brash style made him an annoyance to the mayor, who forced him out.

Though de Blasio was elected as a sharp critic of a police tactic that involved stopping and searching huge numbers of young black men, he picked Bratton as a sign that he would balance reform with further efforts to drive down crime.

On Bratton's watch, the NYPD has drastically scaled back its "stop-and-frisk" strategy, but stepped up enforcement against of so-called "quality of life" offenses. Critics said that approach still unfairly targeted minorities and came into play in the chokehold death of Eric Garner during his arrest for allegedly selling loose cigarettes. Garner, who was black, was unarmed; Officer Daniel Pantaleo, who put his arm around Garner's neck, is white.

Adding to a national wave of concern about police treatment of minorities, Garner's 2014 death and a grand jury's decision not to indict Pantaleo sparked protests and tension between the mayor and rank-and-file officers who felt he took protesters' side.

Then Officers Wenjian Liu and Rafael Ramos were ambushed and shot dead by a gunman who had announced online he planned to kill police in retaliation for Garner's death. In an extraordinary display of scorn, officers turned their back on the mayor at a hospital on the night of the December 2014 killings and again at the officers' funerals.

Bratton found himself in the middle, calling the officers' gesture inappropriate but at the same time noting that it reflected officers' feelings about "many issues."

The tensions between the mayor and police eased, but officers have been under scrutiny this summer as concern about police-minority relations has welled anew here and elsewhere.

On Monday, Bronx state Assemblyman Michael Blake, who is black, filed an excessive-force complaint against the NYPD, saying an officer handled him roughly as Blake tried to defuse an argument between officers and residents. The department said that the officer perceived a possible threat to a sergeant when Blake placed a hand on his shoulder and that the officer had apologized.

Bratton's resignation comes a day after Quinnipiac University released a poll finding New Yorkers are sharply divided on how the city is handling crime, but more than half of respondents approving of how Bratton was handling his job.

As tensions between the police and minorities have grown, the mayor, were he to be re-elected next year, will likely be under pressure by his liberal allies to select a more progressive candidate, and likely a commissioner of color.