Ali Bashar, 22, had admitted in court in Wiesbaden that he strangled Susanna Feldman on 23 May 2018, but claimed he did not know how it happened.
Her body was found two weeks later after he had returned to northern Iraq.
The killing prompted outrage in Germany and led Chancellor Angela Merkel to call for faster deportation of failed asylum seekers in the country.
Bashar was sentenced on Wednesday amid tight security at the court in Wiesbaden, the city where the murder took place.
As his crime was deemed by the judge to be of exceptional severity, he is unlikely to be granted parole after 15 years.
Bashar denied raping Susanna and claimed that they had consensual sex.
During the trial, he described through an interpreter how his family had fled Iraq in 2015.
He then talked about his time in Germany, and how – despite consuming alcohol from the age of 12 – it was there that he was first introduced to harder drugs.
He claimed that he had met Susanna through a mutual acquaintance three months before the attack and had spent time with her, listening to music and walking with her, hand in hand. He had not known her age, he said.
Speaking of the incident, Ali Bashar told the court: “Everything went black before my eyes, then it all happened. I don’t know how it could have happened.”
On 6 June 2018, Susanna Feldman’s body was found in a shallow grave covered with leaves, twigs, and soil after police were given information from a 13-year-old Afghan boy from Bashar’s asylum shelter.
By the time she had been found, Bashar and his family had traveled to the Kurdish city of Irbil in northern Iraq where he was then detained by local forces.
As Iraq and Germany do not have an extradition treaty, a high-profile mission began involving the head of German federal police, Dieter Roman, who traveled to Irbil with anti-terror police to bring him back.