The Berlin state court ordered Ralf Meyer, 41, into psychiatric care.
Meyer, who went on trial last week, had acknowledged killing Joe Ritzkowsky, a 33-year-old music teacher from Berlin who answered an internet solicitation for sadomasochistic sex.
Meyer “must be dealt with accordingly and locked away,” presiding Judge Peter Faust said as he announced the verdict.
Meyer’s defence team has said he was inspired by the case of Armin Meiwes, who was convicted in January 2004 of killing and eating a man he met online.
In the Berlin case, Mr Ritzkowsky’s corpse was dismembered and parts were stored in Meyer’s refrigerator in his apartment, but Meyer testified that, after the killing, he was too disgusted to actually eat the body parts.
Meyer said in a closing statement to the court: “I would like to apologise to the people who knew him, his friends and his mother.”
Prosecutor Johannes Kroll had called for Meyer to be sentenced to 14 years and nine months. The defence asked the sentence be limited to 10 years, saying he did not premeditate the killing.
Mr Ritzkowsky was likely suffocated, but a doctor testified he could not be certain of the exact cause of death because the corpse was so badly mutilated.