CCTV showed two attackers chasing the victim through the streets and into Westcliff-on-Sea station on Monday 22 October last year.
They were joined by a third man at the station; 19-year-old Abdi Hashi who is seen in the footage wearing a black and red tracksuit.
All three cornered the victim, aged in his late teens, on a waiting train and stabbed him six times to the neck, chest and leg.
Fortunately, his life was saved by an off-duty nurse and a member of St Johns Ambulance who were on board.
He was then taken to a hospital in London where he underwent emergency surgery and spent the next two weeks in hospital.
The attackers; Hashi and a 17-year-old, who cannot be named for legal reasons and was seen on CCTV carrying the machete, were both found guilty of causing Grievous Bodily Harm.
Both were jailed at Basildon Crown Court on Friday 12 July; Hashi receiving 13 years in prison, and the 17-year-old receiving eight and a half years.
The court heard the victim had been chased from a nearby takeaway. CCTV footage showed the 17-year-old running after the man with a knife alongside the unidentified teenager.
Hashi was seen joining the group at the station; throwing his bike aside at the entrance and running in.
All three fled the train when it arrived at another stop.
Hashi and the 17-year-old were tracked down and arrested a week later; Hashi at his home in Grange Farm Close in Harrow, and the 17-year-old at his home in Southend.
DCI Sam Blackburn of the British Transport Police said: “It’s very fortunate that this attack did not result in a death; and it’s a testament to the professionalism and skill of the attending medics that the young victim will live another day.
“The victim and his attackers were known to each other and the incident itself is believed to have been gang related. Nevertheless, this was a vicious assault which is thankfully something we rarely experience on the rail network.
“Both attackers will now serve a substantial period of their adult lives in jail, and I hope the severity of their sentences will force them to question their violent behavior.”