The suspect, who lived in the same house as the murder victim, was arrested for murder earlier on Tuesday.
"He has confirmed that he had had an argument with the deceased and also confirmed that he had killed him," the suspect's defence attorney Christer Holmqvist told news agency TT on Tuesday.
Prior to the arrest, the suspect, an employee at the Blekinge Institute of Technology (Blekinge tekniska högskolan, BTH), threatened a colleague with a knife on Tuesday morning.
The drama began when police received a call about a fight in an apartment building stairwell at 12.41am on Tuesday morning on the island district of Saltö in Karlskrona in southern Sweden.
They arrived to find a man in his twenties who is also connected with the university severely injured, but emergency crews were unable to save his life.
Later on Tuesday morning, police were called to BTH following reports that a man in his 40s had barricaded himself in a room and was armed with two knives.
He was eventually apprehended by police and placed under arrest for suspicion of the killing which took place in the early hours of Tuesday morning.
The men lived at the same address, but Holmqvist would not go into what may have been the reason behind the argument.
According to the local Blekinge Läns Tidning (BLT), the man was employed at the university.
"He threatened to both take his own life and others'. But the situation is now under control. No one is injured," police spokesperson Cindy Schönström-Larsson told the TT news agency following the arrest.
Police commissioner Thomas Pärlklo confirmed at a press conference that both the victim and the suspect had ties to the university, but refused to provide more details.
"It's a matter of keeping the investigation confidential," he told reporters.
Pärlklo added that police had preliminary suspicions about the man's involvement in the killing before he started making threats at the university and was arrested.
Prosecutor Marie Lindström has decided the man should be held on suspicion of murder. He is likely to be questioned later on Tuesday.
According to Sveriges Radio (SR), the man was armed with two knives when he arrived at the school and locked himself in a room. He then contacted police and asked them to take him in.
"The arrest was uneventful and he wanted to be arrested. We simply took him out of the room," police spokesperson Mikael Hässelberg told SR.
The man also reportedly threatened a colleague before barricading himself in a room.
"According to the information I have, an employee at the school was also threatened," university spokesperson Kristina Fridensköld told TT.
The threatened employee sent an email to her colleagues, according to the Expressen newspaper. In the message, she said that someone was threatening her with a knife. She urged everyone to stay in their offices and said that she was unhurt.
A forensic investigation of the murder scene is now under way and police have also begun to knock on doors in the area to gather more information about what may have led to the killing.