Kelvin Gates, 58, was caged for seven months at Paisley Sheriff Court for arming himself with the huge bladed weapon on the day of Scotland’s independence referendum.

The incident took place at around 2pm within the common close where Gates lives in Simons Crescent, Renfrew.

Advocate Robert Frazer, prosecuting, told Sheriff Tom McCartney there was a knock at the door and the householder answered it.

He added: “There was one person at the door — their downstairs neighbour he knows by the name of Joe, although the real name of the accused is Kelvin Gates.

“It was quite apparent the accused was in possession of a machete, which he had in his right hand.

“There was what appeared to be a white poly bag around the handle of the machete and the accused was seen both holding and brandishing it.” The neighbour then closed the door, phoned a mutual friend of theirs and then phoned the police.

Six officers raced to the scene and Gates was arrested and charged.

The terrifying incident was captured on a CCTV camera in the common close and was shown to the court.

It showed Gates, wearing a white top and dark trousers, walking up the stairs with the machete in his right hand and banging on the door three times with the weapon.

He then hid the machete behind his back until the door was opened and then waved it in the air, pointed inside the flat with his other hand and walked back down the stairs.

When he appeared in the dock at Paisley Sheriff Court last month Gates admitted being in possession of the weapon in a public place on September 18 last year.

Sentence was deferred so he could be assessed by social workers and he returned to the dock on Thursday to learn his fate.

Terry Gallanagh, defending, said Gates had reached the age of 58 with only acquiring one previous conviction and had snapped because of alleged treatment towards him by his neighbours.

He said: “Essentially this offence is borne out of frustration.

“Mr Gates has lived at the same address for in excess of 21 years without incident and without disturbance until the complainers moved in."

He added: "He absolutely accepts his conduct on the day in question is inappropriate and extremely serious. He regrets it.

“He in the past has sought mediation but intimates the family of the complainers did not attend at arranged meetings.

“He accepts his conduct is inappropriate, illegal and has jeopardised his own welfare.” The lawyer said that Gates, who used a stick to walk and is understood to be awaiting a hip operation, was “extremely vulnerable man, both physically and mentally.” And he asked Sheriff McCartney to spare Gates prison and impose a Community Payback Order (CPO).

He said Gates was drunk at the time and could be sent for alcohol counselling as part of a CPO.

But the sheriff ruled there was only one way he could deal with Gates, and locked him up.

As he jailed him for seven months, reduced from nine because he admitted his guilt, the sheriff said: “I can understand living in a situation where there is conflict with neighbours but it’s particularly dangerous in a situation of tension and conflict to have with you an offensive weapon.

“The weapon in this case was a machete — a particularly fearsome weapon, as seen on the recording, capable of great harm.

“It must be clear that having such a weapon with you will be dealt with seriously by the courts.

“I do not consider any alternative to prison is an appropriate sentence.”