Lee Mullen (24) attacked Scott Napier at a house in Cullen Drive, Glenrothes, on July 26 last year.
A judge told Mullen at the High Court in Edinburgh: "You have pleaded guilty to a very serious and premeditated assault which endangered the victim's life and left him permanently scarred."
Lord Tyre said that Mullen would have faced a four and a half year sentence for the crime but for his guilty plea.
Mullen and an accomplice, Josh King (18) earlier admitted attacking Mr Napier to his permanent disfigurement and the danger of his life.
Mullen was told he will be supervised for 12 months following his custodial sentence.
King was ordered to be detained for three years, and was also placed on a 12 month supervision order.
Advocate depute William Frain-Bell told the court that Mullen bought the 40cm long machete from a shop in Leslie on the day of the attack.
The prosecutor said: Mullen was asked for a form of ID and produced a Young Scot card which contained his home address and date of birth."
The details were recorded in the shop's knife register.
Mullen met up with King and the pair went to the victim's house.
When Mr Napier answered the door King wrongly accused him of breaking into his sister's home.
Mr Napier denied the allegation but was then "repeatedly struck with force" with the machete. The attackers left the scene leaving the victim to shout for help.
Police found the victim in need of urgent medical treatment with an injury to his left forearm and a wound underneath a collarbone.
Doctors said he had sustained an "arterial bleed" in the attack and also suffered muscle and nerve damage.
Iain Paterson, for Mullen, said: "He appreciates the link between substance misuse and alcohol misuse and his offending. He appreciates the harm he has caused to the complainer and he apologises for that."
Mr Paterson said Mullen had a fall-out with his partner and went on "a drinking spree for a number of days" before the offence was committed.
Defence solicitor advocate Gordon Martin said that King accepted that it was "a nasty incident". He said that the teenager appeared to be trying to make something of himself while in custody and has taken up educational opportunities.