NEW YORK - (AP) -- New York City Police Commissioner William Bratton is leaving the nation's largest police force, after getting credit for keeping crime down but grappling with tension between police and minority communities.
Bratton, whose departure was announced Tuesday, will leave next month to become a risk and security adviser at Teneo, a consulting firm. James O'Neill, the department's top chief, will replace him as commissioner.
During five years spanning two stints as the city's top cop, Bratton has had an outsized impact on the New York Police Department. He noted that he was leaving at "a challenging time for police in America and New York, even though all indicators are pointing in the right direction."
He said no department is better prepared to confront "the crises of race in America, crime in America, the threat of terrorism" and the divisiveness of the presidential election.
The announcement by Mayor Bill de Blasio took New Yorkers by surprise. Bratton, 68, said last week he would leave by the end of 2017 "when I find the right time," though the mayor said Tuesday that Bratton had actually disclosed his plans more than three weeks ago.
De Blasio called Bratton's contributions to the city "inestimable and extraordinary," while heralding O'Neill as someone who would "take this department where it's never been before" by leading a push toward neighborhood policing, or trying to build trust and working relationships between law enforcement and communities. O'Neill has been heavily involved in the city's plans to shift toward that strategy during Bratton's tenure.
"We've tried to redefine our relationship from being the police to being your police," Bratton said.
Yet NYPD critics said Bratton hadn't come close to ending discriminatory and abusive policing. They questioned whether elevating his second-in-command -- a decision the mayor made without any public discussion or input -- would make a difference.
"So-called 'community policing,' 'training' and the rhetoric of 'police-community relations' are no solution to the systemic problems with policing in this city and nation," Communities United for Police Reform, a group that advocates for changing police practices, said in a statement.
O'Neill, 58, a Brooklyn native, started as a patrolman in the transit system over 30 years ago. He has been chief of department, the department's highest uniformed position, since November 2014.
Bratton, 68, began his career as a patrolman in Boston in 1970 and built a resume unmatched in local law enforcement, heading police departments in Boston, Los Angeles and New York.
In his first tenure as NYPD commissioner in the early 1990s, Bratton was credited with driving down crime with a widely copied, data-driven strategy before his brash style annoyed then-Mayor Rudolph Giuliani, who forced him out.
De Blasio was elected as a sharp critic of another police tactic called stop-and-frisk, which involved stopping and searching huge numbers of people, overwhelmingly black and Hispanic. The Democratic mayor picked Bratton as a sign that he would balance reform with further reducing crime.
But "there's no way Bratton could have foreseen the firestorm he walked into," said Eugene O'Donnell, a former NYPD officer who's now a John Jay College of Criminal Justice professor. "He wanted to re-educate the police department. ... Instead, he's been trying to fend off attacks on the profession."
On Bratton's watch, the NYPD has drastically scaled back stop-and-frisk, but stepped up enforcement against so-called quality-of-life offenses. The approach is known as "broken windows," shorthand for the theory that reining in small crimes helps deter more serious ones.
Critics said it unfairly targeted minorities and came into play in the chokehold death of Eric Garner during his arrest for selling loose cigarettes. Garner, who was black, was unarmed; Officer Daniel Pantaleo, who put his arm around Garner's neck, is white.
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 two officers were killed by a gunman who had announced online his plans 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 while noting that it reflected their feelings.
The tensions between the mayor and police eased, but officers have been under scrutiny this summer as protests over police-minority relations have welled anew here and elsewhere.
Still, Bratton said, "we are farther along in New York City than most places" in improving relationships between police and minorities, thanks to training and other measures.
Meanwhile, two high-ranking officers and a businessman have been arrested in an ongoing corruption probe. Prosecutors say the officers accepted $100,000 in free flights, prostitutes, and other bribes in return for arranging police escorts, special parking and gun permits.
Teneo, the consulting firm hiring Bratton, said in a statement that he will head a new division that will advise companies and CEOs on a range of issues from cyber-security to city planning to crisis response. The firm was founded by Douglas Band, a former aide to President Bill Clinton. A longtime aide to current Democratic presidential nominee Hillary Clinton, Huma Abedin, worked for the company in 2012 while also advising Clinton at the State Department.
The mayor, if re-elected next year, may be under pressure by his liberal allies to select a more progressive candidate than Bratton, and likely a commissioner of color.
O'Neill, like Bratton and de Blasio, is white.
Associated Press writers Jonathan Lemire in Ashburn, Virginia, and Verena Dobnik in New York contributed to this report.
This story has been corrected to show that Garner and officers Liu and Ramos died in 2014, not 2012.