A man accused of murdering his transgender ex-partner has pleaded guilty to a federal hate crime charge – the first such conviction in US history.

17-year-old Alabama teenager Mercedes Williamson was beaten to death with a hammer in June 2015.

Her ex-boyfriend Joshua Vallum, now 29, was arrested and charged with the murder, and later admitted targeting her because of her transition. In addition to his murder conviction, Vallum pleaded guilty to a federal hate crime charge – the first use of hate crime laws in a case involving a transgender victim.

The charge was brought under federal law using the 2009 Matthew Shepard and James Byrd Jr Hate Crimes Prevention Act, as Mississippi hate crime law does not apply to gender identity, the federal law ensured justice was brought.

The Hate Crimes Prevention Act was signed into law by President Barack Obama in 2009, added federal-level hate crime protections for crimes based on gender, sexual orientation, gender identity, or disability. It became law more than a decade on from the homophobic murder of Mathew Shepard that led his parents to campaign for hate crime laws.

After news of the conviction broke, Attorney General Loretta Lynch said: “Our nation’s hate crime statutes advance one of our fundamental beliefs: that no one should have to live in fear because of who they are. Today’s landmark guilty plea reaffirms that basic principle, and it signals the Justice Department’s determination to combat hate crimes based on gender identity.

“While Mississippi convicted the defendant on murder charges, we believe in the fundamental value of identifying and prosecuting these bias-fuelled incidents for what they are: acts of hate.

“By holding accountable the perpetrator of this heinous deed, we reinforce our commitment to ensuring justice for all Americans.”

The Justice Department’s Civil Rights Division head Vanita Gupta said: “Congress passed the Shepard-Byrd Act to protect our most vulnerable communities, including the transgender community, from harm. No conviction, even such a historic one, can relieve the grief and anguish facing this victim’s family.

“But this guilty plea sends an unequivocal message that violence based on one’s gender identity violates America’s defining values of inclusivity and dignity.

“The Justice Department will continue to vigorously prosecute hate crimes, which not only target individuals for harm, but also deny entire communities the promises of true freedom and equal protection.”

Vallum faces up to life in prison and a $250,000 fine.