William Gross is stepping down as Boston Police Commissioner, Mayor Walsh's office announced Thursday.

Walsh said in a statement Thursday that Gross is retiring from the department and that he is appointing Dennis White as Gross' replacement. Gross led the Boston Police Department for the last two and a half years and was the first African American to hold the position. He served in the department for 37 years.

"Throughout his decorated career, he's always embodied the spirit of community policing that is so important to building trust with the people we serve," said Mayor Walsh in a statement. "We can all be proud of the legacy he'll leave behind, from reducing major crime to helping undertake the most ambitious set of police reforms in the department's history."

Gross thanked the department and said in the statement that he decided to retire “only after long and careful consideration.”

“My heart will always remain alongside my brothers and sisters of the BPD,” he continued. “I will continue to be one of their biggest champions as I move forward with my next chapter."

Walsh tapped Gross — who began his tenure with the BPD as a street cop in 1985 — to lead the department in 2018. At the time of his appointment, Gross commented on its significance in a city with a long history of racism.

“It shows that any kid in Boston that they will have the opportunity to be mayor or commissioner or chief, if we all work together,” Gross said at a July 2018 news conference. “If you want change, be change. That’s why I became a police officer.”

Ed Gaskin, executive director of Grove Hall Main Streets, said he was a fan of Gross. Gaskin described him as a steady and fair law enforcement leader, particularly when it came to understanding the concerns of business owners and criminal justice reformers who held opposing view points over District Attorney Rachael Rollins' controversial decision to shift resources away from prosecuting low-level offenses like shoplifting.

Activist Jamarhl Crawford said while Gross’ tenure was historic, parts of his record are problematic. He cited Gross' criticism of judges who released repeat offenders, his willingness to meet Trump-era Attorney General William Barr, and his praise of officers who appeared to use excessive force the night that peaceful protests broke down into unrest and looting last summer.

“I can’t say that I saw any sea change in quality of life for communities of color, specifically the Black community,” said Crawford, a member of the police reform task force that recommended greater oversight and accountability of the BPD.

The announcement fueled speculation among some who closely follow Boston politics that Gross will soon announce a run for mayor, potentially joining an already crowded field of candidates vying to replace Walsh. Boston City Councilors Michelle Wu, Andrea Campbell and, most recently, Annissa Essaibi George have all officially jumped into the race. President Biden has nominated Walsh to his cabinet as labor secretary.

About two weeks ago, Gross said he was thinking about running for mayor.

"Out of respect, I sure am considering every thought and every prayer that comes my way, that people want me to be a mayoral candidate — deep consideration," Gross told WCVB.

GBH News reached out to the Boston Police Department to ask about Gross' future plans, but a spokeswoman for the department was unable to provide any details.

White, who currently serves as superintendent in the department and chief of staff to Gross, will lead the BPD beginning Friday and will become the second Black commissioner.

"I want to thank Mayor Walsh for entrusting me with this incredible opportunity and the responsibility of leading our historic department,” White said in a statement. “Serving as Commissioner is the honor of a lifetime, and I will never take this sacred duty for granted."

Reporter Saraya Wintersmith contributed to this article.