Dean Williams struck Craig Essen after a fracas outside a pub in Mayfield, Midlothian.
Williams had stormed to the pub thinking his girlfriend, a barmaid, had been unfaithful.
He attacked Mr Essen, 28, from Dalkeith, who it turned out had nothing to do with the woman.
Williams admitted to a culpable homicide charge at the High Court in Glasgow.
A judge warned the 21-year-old he faces a lengthy jail term next month.
The court was told how Williams had been dating 22-year-old Melissa Carr on and off for the past six years.
Williams heard Miss Carr had been flirting with another man while working at the Rowan Tree Pub.
Hours before the killing last November, Williams had been out at local bars with a friend before going to his mother's home.
He stayed there for a short time before going back out to the Rowan Tree.
CCTV played in court showed Williams battering a glass window while armed with a knife.
Mr Essen and his friends then stepped in to help.
Williams was forced outside into the car park - but he came back at the group with the blade.
He then tried to run off, but fell on the ground before a fight broke out. Mr Nicol told the court that during this struggle, he lashed out with the knife striking Mr Essen in the chest. CCTV showed Mr Essen staggering away back into the bar.
Lord Matthews adjourned sentencing for reports.