A former Southern California man who convinced troubled girls as young as 12 to perform masochistic acts and urged one to become his sex slave was sentenced Tuesday to 27 years in federal prison.

Matthew Christian Locher was "a parent's worst nightmare," U.S. District Judge Dolly M. Gee said during his sentencing in Los Angeles, the U.S. attorney's office said in a statement.

Locher pleaded guilty last August to one count of sexual exploitation of a child for the purpose of producing a sexually explicit visual depiction.

MAN WHO CONVINCED GIRLS TO PERFORM MASOCHISTIC ACTS, URGED 12-YEAR-OLD TO BE HIS SEX SLAVE PLEADS GUILTY

In his plea agreement, prosecutors said Locher, 32, acknowledged that while living in Redondo Beach in 2020 and 2021, Locher got into online conversations targeting girls suffering from mental health issues such as depression, schizophrenia, anorexia and suicidal thoughts.

"Locher groomed his victims to engage in self-mutilation and instructed a victim struggling with an eating disorder to starve herself, ordering her to film herself cutting her body when she disobeyed him," the U.S. attorney’s office statement said.

Fox News California graphic

Matthew Christian Locher was sentenced to 27 years in federal prison. (Fox News)

Two girls sent him images and videos of self-harm that included cutting their breasts with razor blades, prosecutors said.

He convinced a third victim, who was 12, to run away from her Ohio home and attempt to reach California to have sex with him, prosecutors alleged.

CLICK HERE TO GET THE FOX NEWS APP

Encouraged by Locher, the girl first set fire to her home in a failed bid to kill her parents, prosecutors alleged.

Locher had promised he would pick her up, "bring her to California, and make her his ‘slave,’" the U.S. attorney’s office said.

Locher moved to Indiana in 2021 after authorities searched his home. He was arrested in January 2022 in Indianapolis and sent back to California.