GULFPORT, Miss. -- A Mississippi man received a 49-year prison sentence Monday for the first-ever conviction on federal hate crime charges arising from the murder of a transgender woman.

U.S. District Judge Louis Guirola Jr. sentenced Joshua Vallum in connection with the 2015 killing of 17-year-old Mercedes Williamson. It was the first case prosecuted under the federal Hate Crimes Prevention Act involving a victim targeted because of gender identity.

Prosecutors said Vallum shocked Williamson with a stun gun, stabbed her and beat her to death in 2015 to keep fellow Latin Kings gang members from discovering the two had been having sex. Gang rules barred homosexual activity and declared that punishable by death, the prosecutors had said.

Get Breaking News Delivered to Your Inbox

Guirola could have sentenced Vallum to life in federal prison, but stuck to a lesser sentence suggested in a plea agreement between defense attorneys and prosecutors, citing Vallum's neglected childhood and other issues. Both the judge and defense lawyers said Vallum's history of abuse as a child had to be considered.

Mercedes Williamson WLOX-TV/George County Sheriff's Office

Vallum pleaded guilty to the federal charges in December, and it's unlikely he'll ever leave prison. He also had pleaded guilty earlier to a state murder charge that drew him a separate sentence of life without parole.

The case has been closely watched by LGBT advocates nationwide, who applaud federal officials' first use of a 2009 hate crimes law to prosecute an offense against a transgender person.

"The taking of a human life because a person has a particular gender identity is particularly heinous and cannot be tolerated in an enlightened society," Guirola said.

At sentencing in federal court in Gulfport, Vallum begged forgiveness Monday from Williamson's family and friends, but none of them were present to hear his words -- only a few reporters, the judge and Vallum supporters.

"Every day, I live with the guilt and regret of my actions." Vallum said. "If I could bring back Mercedes by giving up my life, I would gladly do so."

Federal prosecutor Julia Gegenheimer had said during Vallum's plea hearing in December that he began planning to kill Williamson after a friend called him May 28, 2015, to say he'd discovered her identity.

Vallum lured Williamson into a car in Alabama and drove her 50 miles to his family home near Lucedale, Mississippi, prosecutors have said. He shocked her with a stun gun and stabbed her in the body and head with a pocketknife, they added. Prosecutors also said that when Williamson tried to run into the woods, Vallum chased her down and bashed her in the head with a hammer.

Prosecutors said Vallum tried to ditch the murder weapons along with other evidence linking him to the crime, CBS affiliate WLOX in Jackson reports.

Attorney General Jeff Sessions issued a statement Monday afternoon reacting to the sentencing.

"Today's sentencing reflects the importance of holding individuals accountable when they commit violent acts against transgender individuals," he said. "The Justice Department will continue its efforts to vindicate the rights of those individuals who are affected by bias motivated crimes."

At Monday's hearing, public defenders submitted a sealed brief to Guirola outlining Vallum's troubles.

"Mr. Vallum lived through a childhood that was characterized by abandonment and neglect," said public defender Ellen Allred. "It's difficult to image how a mother could lock a two- or three-year-old child in a room for house on end while adults did drugs."

Allred said Vallum first tried to kill himself when he was age 7 or 8.

"We can't go back and change Mr. Vallum's childhood, just like Mr. Vallum can't go back and undo what he did to Mercedes," Allred said.

Vallum initially told sheriff's deputies and later told The Sun Herald newspaper that he found out that Williamson had a penis on May 30, 2015 -- moments before he killed her. He said he "blacked out" and doesn't remember the crime, a variation of what's known as a "gay panic" or "trans panic" defense.

He declined to speak with The Associated Press in a March letter, citing advice from his lawyers, and didn't address the issue Monday. However, his lawyers have never contested evidence that Vallum had long known Williamson was transgender.

A witness in state court had testified previously that Vallum and Williamson had sex multiple times while the witness was a roommate with Williamson. The roommate also testified that Vallum once told her and Williamson his gang would kill Vallum and Williamson if Williamson's transgender status was discovered.

Williamson had transitioned from male to female before dropping out of high school in Alabama, distancing herself from her parents while drifting from place to place.