Peter Breidenbach, a 58-year-old detainee convicted for multiple rapes, was on a supervised visit under police guard in his hometown of Cologne when he told guards he needed the restroom.

Police say they decided to use a landmark brewery next to the city cathedral and the serial rapist managed to give his guards the slip while they too were relieving themselves.

A manhunt ensued. Three days later he was caught 15 kilometers (9 miles) away after he tried to buy a bicycle with a debit card. There are questions of how such a blunder could happen and police have promised a full investigation.

A key detail is that Breidenbach was not an ordinary prisoner - he'd already served a nine-year sentence for rape in 1999. But shortly before his release a court deemed him dangerous and ordered his confinement to continue under a measure called 'preventive detention' - and he's been held in custody ever since.

"Detainees are not prisoners - they are privileged in a way," explained Torsten Verrel, a professor of criminology at the University of Bonn.

There are about 500 such detainees - a relatively small number within Germany's 50,000 prisoners population. But their existence has caused years of wrangling within German courts and the European Court of Human Rights on the principle of indefinite detention for potentially violent people.

For such cases, Verrel explains, "The end of their sentence is not fixed - it depends on the prognosis. That could mean a person spends the rest of their life in detention."

That's led to a difficult balancing act between protecting the public from potentially violent offenders and revoking a person's liberty - locking them up and throwing away the key.

German prison guards face a criminal investigation after they allowed a convicted rapist to escape during a visit to Cologne's landmark Früh brewery in the busy city center.

A brief but troubled history of preventive detention

Germany's constitution forbids a person to be punished twice for the same crime. But Germany also has relatively short prison sentences compared to other European countries. Preventive detention was sometimes used to keep people deemed dangerous in custody longer, but there was a cap of ten years.

This ten-year limit was lifted in 1998. Six years later another law allowed courts to order preventive detention retroactively to prisoners up until shortly before they were to be released, effectively allowing a person's sentence to be extended at the will of the court.

The numbers of people in preventive detention began to increase as did appeals to the European Court of Human Rights in Strasbourg. Many detainees argued that the practice violated both Article 5 (liberty and security) and Article 7 (retroactivity). The former ensures the right to due process; the latter says a court can't reach back in time and extend a person's sentence.

In late 2009, the ECHR ruled Germany in breach of these two articles when a state court retroactively extended the detention of a serial burglar's conviction on attempted murder beyond the ten-year limit after he'd been sentenced.

"After that there have been a number of judgments concerning different aspects of preventive detention," a ECHR press officer said.

Germany's Federal Constitutional Court ruled in 2011 that German laws - despite some reforms - were in breach of the German constitution and ordered tens of thousands of euros paid in compensation to four offenders convicted of child rape and attempted murder but had each been held for more than a decade after completing their sentences.

"There are people who are dangerous which can't be treated with the methods we have now. On the other hand, we cannot be unfair to people who are wrongly assessed to be dangerous," says Torsten Verrel, a criminology professor at the University of Bonn.

A mental illness rationale

Germany has changed its laws again. New amendments in force since 2013 ended the power to impose preventive detention retroactively. It also brought in the argument that those in preventive detention suffered a mental disorder or were of "unsound mind," keeping it in line with the European Convention on Human Rights.

In a ruling this month, the ECHR accepted the German court's rationale that 72-year-old Karl-Heinz Bergmann's continued confinement as a detainee is appropriate. Bergmann was sentenced to 15 years in prison in 1986 for two counts of attempted murder and other charges and has remained confined since 2001.

His incarceration is justified, the court ruled, as he has been diagnosed as a sexual deviant and is being provided a therapeutic environment. The European Court rejected his argument he's being punished after his sentence, handing Germany its first significant victory in Strasbourg.

Flash forward to 2016

Germany's institutions now treat detainees differently than ordinary prisoners. Larger, more comfortable cells have been designed to draw a clear distinction between prisoners serving fixed sentences and those confined indefinitely under preventive detention.

But there are critics who say the reasoning to offer enhanced therapy for mental disorders and enhanced conditions is more legal gymnastics to satisfy legal requirements than a good faith effort to rehabilitate.

Kirstin Drenkhahn, professor of criminology at the Free University in Berlin, notes there are already legal measures to confine people who suffer serious mental disorders. Yet preventive detention is being ordered for convicts of "unsound mind" who were deemed mentally fit for trial before they were sent to prison.

"A lot of people think it doesn't really make sense because in the beginning these people were considered criminally culpable," Drenkhahn said. "They were probably just really not nice people but in hindsight now they are being considered having a mental disorder and are dangerous."

Part of the deal is that detainees are allowed more supervised releases. In the state of North Rhine Westphalia - where Breidenbach has been held for decades - even so-called dangerous detainees have the right to day trips.

"North Rhine Westphalia has a rule that those in preventive detention have the right to go out even if they are an escape risk," Verrel said. "That is, if it's possible to minimize this danger."

Which may explain why the serial rapist was allowed to tour a crowded city center.