OAKLAND — A San Francisco man brutally beaten by Alameda County sheriff’s deputies has settled his civil rights lawsuit for $5.5 million, his attorney said Friday.

The November 12, 2015 beating of Stanislav Petrov led to the firings of three deputies, charges against two of them and department reforms after a high-quality video showing deputies in an alley in San Francisco striking Petrov some 40 times with batons went viral.

The baton strikes left Petrov with broken bones, head trauma, blunt force injuries and permanent disability and disfigurement, attorney Michael Haddad said.

“We said we were going to hold Alameda County and the involved deputies accountable and we did,” Haddad said. “This result should serve as a deterrent to law enforcement officers who would abuse their authority and beat a man who was trying to surrender, as these deputies did.”

Petrov is currently in federal custody awaiting trial on weapons and drug charges. He was arrested in a FBI raid at his San Francisco home in March 2016, four months after his confrontation with Alameda County deputies.

Haddad said the county will pay $1 million and the county’s insurance will cover $4.5 million. The money will be placed in a trust and paid over his lifetime, the attorney said. The sum is one of the highest settlements in recent memory for the county, excluding wrongful death suits.

It all began in the early morning hours of Nov. 12, 2015 when deputies tried to pull Petrov over for driving a stolen car. He allegedly rammed a patrol car and led deputies on a 40-minute chase across the Bay Bridge into San Francisco, where he ran out of his car in a Mission District alley.

Video from a nearby home shows deputies Luis Santamaria and Paul Weiber tackle Petrov and pummel him dozens of times with their batons, as he moaned for help. Santamaria and Weiber were later charged on felony counts and fired.

A third deputy, Shawn Osborne, was fired for allegedly stealing a gold chain from Petrov and using it to bribe two homeless people who witnessed the beating.

“When your officers act outside of policy and something like this happens you are going to pay,” said Sgt. Ray Kelly, a sheriff’s spokesman. “The gold chain incident brought this from a really bad incident and turned it into a scandal that really hurt some community trust.”

As a result, Kelly said the department changed its policy to require deputies to activate their body cameras and review when it is appropriate for police to pursue suspects in car chases. It also led Sheriff Gregory Ahern to meet with each deputy to discuss personal ethics.

“Although this was not our proudest moment it is not going to define who we are and the belief we have in making our community a better place,” Kelly said.