John Morris (42) repeatedly wounded Douglas Bamford in a street confrontation in Motherwell, in North Lanarkshire.
A judge told Morris at the High Court in Edinburgh: "This was a brutal and violent, sustained attack perpetrated with a bladed weapon."
Lord Armstrong said Morris, who has 53 previous convictions, including crimes of violence and weapon possession, was assessed as posing a high risk of re-offending.
The judge said he would have jailed Morris for six and a half years if he was convicted of the offence after trial, but the sentence would be modified following his guilty plea.
Lord Armstrong said he had accepted responsibility for his criminal actions and has expressed remorse.
Morris earlier admitted assaulting Mr Bamford to his severe injury, permanent disfigurement and to the danger of his life by repeatedly striking him on the body with the weapon at Northfield Street, Motherwell, on July 1 last year.
The victim sustained four wounds to his torso and a further injury to his thigh.
He was admitted to a hospital high dependency unit for observation.
Prosecutor Angela Gray said: "His condition at that stage was described as critical."
Defence solicitor advocate Rhonda Anderson said the victim was the ex-partner of Morris' sister, Wendy.
Morris was staying at her address.
She said the victim, who was visiting, became abusive and was asked to leave but continued to shout outside in the street.
She said that during a confrontation between the two men there was an exchange of punches.
Ms Anderson said of Morris: "He advises he never intended to use the knife to injure the complainer, but obviously he did."
"He recognises he will have to address underlying anger management issues," she told the court.
She said that Morris was of no fixed address and began drinking at the age of 12 and later abusing drugs.