Image copyright Facebook

A Mississippi man has been sentenced for killing a transgender woman in the first US federal prosecution of a hate crime based on gender identity.

Joshua Vallum was given 49 years in prison for the murder of his 17-year-old ex-girlfriend Mercedes Williamson.

Vallum pleaded guilty to stabbing and bludgeoning Mercedes after friends learned of their relationship.

Transgender-rights advocates say there is an "epidemic of violence" against the minority community.

"Today's sentencing reflects the importance of holding individuals accountable when they commit violent acts against transgender individuals," US Attorney General Sessions said in a written statement.

"The Justice Department will continue its efforts to vindicate the rights of those individuals who are affected by bias motivated crimes," the former Alabama congressman added.

In 2009 Congress expanded the federal hate crime law to include crimes motivated by a victim's sexual orientation.

This case, which began under the Obama administration, is the first federal hate crime prosecution based on a victim's gender identity.

The 29-year-old member of the Latin Gangs street gang had secretly been romantically involved with Mercedes during the summer of 2014, he admitted to prosecutors.

Image copyright Facebook Image caption Vallum admitted to killing Mercedes because she was transgender

He knew that she was transitioning from male to female at the time, despite initially telling officers that he "blacked out" and killed her after seeing her penis.

Experts refer to this legal technique as the "gay panic" or "trans panic" defence.

After their relationship had ended, Vallum made the decision kill Mercedes fearing retribution from other gang members who had discovered their past.

He lured her to his father's home, where he shocked her with a stun gun, then stabbed her and struck her with a hammer as she tried to flee.

During sentencing, Vallum pleaded for forgiveness from Mercedes' family, although none of them were in court.

"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."

At least nine transgender people have died in 2017 in the US, according to LGBT advocates.