The district court ruled that the man be kept in care under special discharge conditions.
According to the National Board of Health and Welfare (Socialstyrelsen) legal advisory board, the man suffers from a serious psychiatric condition.
He has previously admitted to killing his 19-year-old neighbour in January in a frenzied knife attack, blaming his actions on the "creaking" noise coming from his flat.
The man has however indicated that he is unable to remember the entire sequence of events.
According to a statement released by prosecutor Pernilla Åström, the man said he felt bothered by the noise and armed himself with a large knife before ringing the bell on his neighbour's door.
He proceeded to stab the 19-year-old repeatedly. The young man later died in the building's stairwell from his injuries.
After the stabbing, the 39-year-old made his way to the Blekinge Institute of Technology, where he worked. He then sent an email to the local Sydöstran newspaper explaining what he had done and where he was.
He requested that someone from the newspaper alert the police.
But no one from the Sydöstran's editorial offices read the email until after the 39-year-old had already been spotted by another employee at the university, who in turn called police.
The man, who had barricaded himself in a room at the university, was later arrested without incident and subsequently admitted to killing the 19-year-old.