(CNN) In the first case of its kind, a Mississippi man pleaded guilty to a federal hate crime Wednesday for murdering his ex-girlfriend because she was transgender.

Joshua Vallum, 29, knew Mercedes Williamson was a transgender teenage girl when they began dating, the US Justice Department's Civil Rights Division said.

Vallum killed her because she was transgender, making him eligible for prosecution under the 2009 Matthew Shepard and James Byrd Jr., Hate Crimes Prevention Act, named for two of the country's most infamous hate crimes.

The federal law criminalizes violence based on race, religion, gender, sexual orientation or gender identity. Vallum's prosecution is the first to involve a victim targeted for being transgender, the Justice Department 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," US Attorney General Loretta Lynch said in a statement.

Read More