CHARLESTON, S.C. -- A white former South Carolina officer who grew up in New Jersey was sentenced to 20 years in prison on Thursday for fatally shooting an unarmed black motorist in the back in 2015, wrapping up a case that became a rallying cry for the Black Lives Matter movement.

Attorneys for ex-North Charleston Officer Michael Slager said he shot 50-year-old Walter Scott in self-defense after the two fought and Scott reached for Slager's stun gun. They said race didn't play any role in the shooting and that Slager never had any "racial animus" toward minorities.

Still, Slager pleaded guilty in federal court to violating Scott's civil rights. As part of the plea agreement reached in May, prosecutors dropped state murder charges. A year ago, a state judge declared a mistrial when jurors deadlocked.

"This is a tragedy that shouldn't have happened," U.S. District Judge David Norton said.

Slager graduated from Lenape High School in Medford, according to Ryan Johnson, spokesperson from the mayor's office in the City of North Charleston.

Slager worked as a waiter in Voorhees after high school before serving six years in the U.S. Coast Guard in Florida, according to his job application given to NJ Advance Media by the North Charleston Police Department.

A bystander recorded the shooting on a cellphone, and it was shared around the world, setting off protests across the U.S. as demonstrators said it was another egregious example of police officers' mistreating African-Americans.

Scott's family testified before the sentence and said they had forgiven Slager.

"I'm not angry at you, Michael. Michael, I forgive you, and Michael, I do pray for you now and for your family, because we've gone through a traumatic time," he said.

The shooting angered local African-Americans who complained for years that North Charleston police harassed blacks, pulling them over or questioning them unnecessarily as they cracked down on crime. The Scott family successfully pleaded for calm, asking everyone to let the justice system run its course.

Two months after the shooting, a young white man killed nine black church members in a racially motivated attacked during a Bible study in Charleston. The family members of the church shooting victims struck a similar forgiveness tone after that attack.

Before the sentenced was handed down, the judge had to decide whether the shooting amounted to second-degree murder or manslaughter. Norton found that it was murder.

The bystander's video started after the struggle between Slager and Scott and showed Scott running away and the officer firing eight times. Scott was hit in the back five times.

After the shooting, Slager picked up his stun gun and placed it next to Scott. Slager contends he was securing the weapon. Prosecutors think he put it there to bolster his self-defense story.

An emotional Slager told the Scott family that he was grateful for their forgiveness.

"This tragic event that occurred in seconds has changed the lives of everyone involved," he said. "With my actions that day, Walter Scott is no longer with his family, and I am responsible for that."

The judge also found that Slager, 36, obstructed justice when he made statements to state police after the shooting.

A pre-sentencing report for Slager found that he committed manslaughter and recommended 10 to nearly 13 years in prison. But the judge was not bound by that decision.

If Slager had faced another state trial and been convicted of murder, he could have been sentenced to anywhere from 30 years to life in prison.

Convictions in police officer shootings are uncommon in the U.S. and prison time is even rarer.

South Carolina has been aggressive in charging white officers who shoot unarmed black people. Four have pleaded guilty in state or federal court in the past six years. But only Slager and former state trooper Sean Groubert, who shot a man as he tried to get his wallet during a seat belt violation check, will have been sent to prison. Groubert was sentenced to five years behind bars.