Hussein K. told the state court in Freiburg on Monday that he had happened across 19-year-old Maria L. as she cycled towards him late at night last October.
In the preceding hours he had shared two bottles of vodka with friends before smoking several joints and then visiting a night club. He then took a tram to the area in which the crime occurred. After he got out he stole a bicycle, but crashed it and injured himself, he recounted.
It was then that Maria L. cycled towards him. He kicked her off her bicycle and held her mouth closed. When she screamed he began to strangle her with his scarf. At some point she lost consciousness due to being strangled.
He then noticed that she was a pretty girl, he said.
“It came into my head - do it, have sex with her.”
He undressed her and, after attempting several times to rape her, he sexually assaulted her with his hand.
At this point he believed he had already killed her, he said. Because he had smeared his own blood on her from a wound he had inflicted on himself when he crashed the stolen bike, he threw her into the river to try and eradicate the evidence.
Several details of Hussein K.'s story appeared to contain contradictions, which he blamed on gaps in his memory.
The defendant also apologized on Monday to the family of his victim.
“I am sorry from the bottom of my heart for what I did,” he said. “I understand that it is very difficult for the family.”
A ruling on the case is expected in December.
It is still unclear how old Hussein K. is, or where he is from, but his arrest in November last year nonetheless created huge media interest, as it has highlighted holes in European security procedures.
Critics of the government's refugee policies also suggest that Hussein K., who had already been convicted of attempted murder in Greece, was only able to enter the country because Germany had stopped controlling its borders.
One of the most controversial aspects of the case is that Hussein K. had been sentenced to 10 years in jail in Greece in 2013 after he pushed a young woman off a cliff on the island of Corfu.
But at the end of October 2015 he was placed on parole with the requirement to report to police every month. Officials then lost trace of him two months after he was released.
He left Greece shortly after being placed on parole, but only a nationwide search was initiated by Greek authorities, not an international one. Neither Interpol nor the Schengen Information System (SIS) were alerted.
Interior Minister Thomas De Maizière said in December that if the Greeks had launched an international search, "the suspect could have been detected at various stages of the systematic checks made by German security authorities".
Hussein K. applied for asylum in Freiburg when he arrived in Germany in November 2015. This was just a few months after the government opened its borders to refugees and during a time when tens of thousands of people were passing into the country each day.
The murder fuelled growing anti-immigration sentiment in the country. The Alternative for Germany (AfD) party and far-right Pegida group capitalized on it, blaming German Chancellor Angela Merkel for the crime and arguing it was the consequence of "uncontrolled migration."