Nicolas Cocaign, 39, appeared in court in the northern city of Rouen for killing Thierry Baudry in January 2007 by punching and kicking him, stabbing him with a pair of scissors and suffocating him with a rubbish bag.
Cocaign then allegedly sliced open Baudry's chest with a razor blade, removed a rib and pulled out an organ which he believed was the man's heart, but which in fact was a lung.
He is accused of eating part of the lung raw and then frying the rest of it with some onions on a makeshift cooker in the cell in the Rouen prison.
"I wanted to take his soul," Cocaign, who at the time of the crime was in custody awaiting trial for attempted armed robbery, allegedly told an investigating judge probing the case.
A verdict is expected on Thursday.