The European Court of Human Rights ruled on Tuesday that Germany acted legally by keeping a murderer locked up for a decade after his sentence expired to prevent him reoffending.

The man was sentenced to ten years in jail in 1999 for murdering a woman while she was out jogging. The then-19-year-old strangled the victim on a forest path with a cable, a tree branch and his hands. He then partly undressed the dead or dying victim and masturbated over her.

Once he had served out his sentence in 2008, a German court ordered he stay in preventative custody as he continued to harbor sadistic sexual tendencies. Psychiatric assessments found there was a high risk that he could commit another murder for sexual gratification if released.

Since 2013 he has been kept in a newly-built preventative detention center at Straubing Prison in southeast Germany. Prior to this he was kept in unconstitutional conditions for a number of years, for which he was paid €12,500 in compensation.

Read more: Pitfalls of Germany's 'preventive detention'

Improved conditions

In its ruling the court noted German authorities had substantially improved conditions for people in preventative detention and had tightened the requirements to keep people in such confinement, stipulating that people must be suffering from a mental disorder.

Germany's constitution forbids punishing a person twice for the same crime, but with comparatively short prison sentences, it has sometimes relied on preventative detention to keep dangerous offenders in custody.

It was previously capped at 10 years but a series of rulings has allowed courts to extend detention at their discretion.

Detainees are kept in relative comfort, compared to normal prison conditions, but some critics say these conditions are largely legal gymnastics to skirt constitutional rules rather than a genuine effort at rehabilitation.

Read more: Preventive detention ruling leaves fate of sexual criminals uncertain