Idris Hassan, admitted attacking Lance Scott Walker, also 18, at the hostel where they were both staying in Gledwood Gardens, Hayes on August 15, 2016.
Hassan produced a large knife and stabbed the budding architecture student without warning, just three days before he was due for a mental health assessment.
The victim jumped out of a window to escape the attack, but Hassan followed him outside and continued to attack him in the street, stabbing him a total of six times.
Hassan denied murder but entered a guilty plea to manslaughter by diminished responsibility at the Old Bailey on Monday April 24.
Prosecutor Ed Brown QC said the plea was accepted by the Crown in light of three psychiatric reports.
Mr Brown said: "Hassan and Mr Walker were both residents of the hostel which provided young people with temporary accommodation.
"The defendant had been placed there following an allegation of criminal damage a few weeks before the killing."
He went on to say that there is evidence the young men did not get along, and that Hassan had not been taking his medication for a "pre-existing mental health problem" which began around 2013.
Hassan had been detained by the court under the Mental Health Act in November 2015, and discharged in May, following a mental health tribunal.
The court heard how Mr Walker was having a meeting at the hostel with an administrative assistant when the defendant walked in carrying a plastic bag.
Hassan was standing behind the victim when he pulled the knife out without warning and stabbed and slashed his back.
Mr Walker jumped out of a window and escaped into the street and Hassan followed him out of the front door, swearing in a foreign language.
The victim stumbled along the street before collapsing face down. Hassan crouched down over him and stabbed him six times in the back.
On his arrest later that day, Hassan was heard to say "That pussy's dead", and "Lucky hit, I could have done it with my fists", the court heard.
Mr Brown said Hassan had various previous convictions for having a blade in public and violence, and was referred after being found with an ISIS booklet.
He had also previously been referred to social services following allegations of physical abuse.
Mr Walker's body was found by police in Gledwood Gardens, close to the junction with Gledwood Drive.
Paramedics treated the young man but were unable to save his life, and he was pronounced dead on the scene.
A local witness described seeing the victim lying on the floor with his shirt off, covered in blood.
Lance Scott Walker was due to start a course studying building and architecture a month after he was fatally stabbed.
Sentencing, Judge Michael Topolski QC said: "It is important to make it absolutely clear that Lance Walker was innocent of any wrongdoing in the immediate period leading up to his death.
"Tragically it was the defendant's very disturbed state of mind that led to the terrible events of August 15 when yet another young life was brought to an end by use of a knife.
"This is a truly tragic case. An 18-year-old boy was stabbed to death in broad daylight in this city."
Judge Topolski handed Hassan a hospital order with a restriction order without limit of time for the public's protection.
Keep up to date with the latest news in west London via the free getwestlondon app.
You can even set it to receive push notifications for all the breaking news in your area.