WASHINGTON — The Baltimore police commissioner, Anthony W. Batts, who arrived in that city three years ago pledging change but lost the confidence of many in his rank and file in the wake of riots in April, was ousted Wednesday by Mayor Stephanie Rawlings-Blake, who said he had become “a distraction” that hindered efforts to fight a recent surge in violent crime.

The mayor acted just hours after the police union issued a report critical of the department’s response to the unrest set off by the death of Freddie Gray, an unarmed black man who sustained a fatal spinal cord injury while in police custody. But Ms. Rawlings-Blake insisted she was responding to a “crime surge,” and not acting to placate the union, whose report said the riots were preventable.

“Recent events have placed an intense focus on our police leadership, distracting many from what needs to be our main focus: the fight against crime. So we need a change,” the mayor said at a City Hall news conference. She added: “This was not an easy decision. But it’s one that is in the best interest of the people of Baltimore.”