Christopher Thompson, 23, from Great Hale, near Sleaford, admitted a charge of attempted murder after stabbing Petras Cirtautas in the chest.
Lincoln Crown Court heard Thompson attacked Mr Cirtautas with the knife after arranging to meet him at Heckington railway station on August 10 last year.
Luke Blackburn, prosecuting, said Thompson made substantial admissions to the offence of attempted murder both at the scene and later to police.
At the time of the offence Thompson was suffering from a psychotic episode and spoke of the “after life”, the court was told.
Mr Blackburn told the court it was an aggravating feature that Thompson took a knife to the scene, but that had to be weighed against his mental state.
Earlier this year a jury found Thompson had attempted to murder his friend after being told he could not enter a plea to the charge because of his mental health issues.
Following his trial Thompson was transferred to a mental health hospital but after further treatment it was decided he was able to enter a plea.
Thompson, previously of Heckington Road, Great Hale, appeared at Lincoln Crown Court in July and pleaded guilty to the charge of attempted murder and a second offence of possessing a bladed article.
The court heard Thompson had since written a letter of apology to his victim.
Thompson was returned to prison following his guilty pleas.
Defence barrister, Jeremy Jaines, said this was a tragic case and Thompson had shown true remorse.
Mr Jaines told the court: “In a moment Mr Thompson went from being a fun loving and cheerful man, son and brother, with no convictions, to a man who attempted to take the life of his best friend.
“All this occured because of the turmoil he was going through.
“He tried to put things right almost straight away.
“He was one of those who called the emergency services, and repeated what he had done.”
Mr Jaines added it was clear from all the witnesses on the day of the offence that Thompson was suffering from mental health issues.
In a witness statement Mr Cirtautas, also known as Peter, described how Thompson had been talking about the after life prior to the attack and then also handed him a knife.
The two men had previously attended St George’s Academy in Sleaford and were old friends, the court was told.
The incident occurred after Mr Cirtautas had travelled by train from Sleaford to Heckington.
Mr Cirtautas was taken to the home of two off duty police officers after Thompson produced the kitchen knife and stabbed him in the chest.
The blow punctured Mr Cirtautas’s lung and he fell to the floor. He spent three days in hospital.
In an updated victim impact statement Mr Cirtautas said he felt close to death and suffered flashbacks after the attack.
But Mr Cirtautas said he was willing to forgive Thompson and support his medical recovery.
Passing sentence Judge Simon Hirst told Thompson it was clear from the doctors who had examined him that he was suffering from a psychotic event at the time of the offence which was aggravated by his use of drugs and stress.
But Judge Hirst said that had to be balanced against the fact he had planned to murder his victim.
Judge Hirst told Thompson: “You chose to take drugs, and you chose to try and take the life of Mr Cirtautas to achieve peace for yourself.”