A student has been convicted of threatening behaviour after he drunkenly stole a sword and used it to smash a local woman’s living room window, telling her he would “slay” her.

Hamish McGregor, 21, consumed “a considerable amount of port” after attending a training night on 12 November at the University Officer Training Corps (OTC) St Andrews premises on City Road.

When the OTC bar shut at 11:45pm, the building was cleared and locked but Mr McGregor was left inside, where he took the three-foot sword from its sheath above a fireplace.

At approximately 1am Jennifer Cooper, who lives on City Road, said that she heard noise coming from her living room. Mr McGregor knocked at the window with the metre-long weapon and shouted words to the effect of “stand and deliver”.

Ms Cooper, 55, left the room to call the police and said she heard the breaking of glass. She returned to find a hole in the window and Mr McGregor standing with his torso inside her living room. Mr McGregor then threatened to “slay” Ms Cooper while continuing to point the sword in her direction.

The police arrived to find Mr McGregor leaning in through the broken window and still in possession of the weapon. He was ordered to release the sword, but refused. Eventually the attending officer drew his baton and struck Mr McGregor on the hands three or four times before he would let go.

On arrest the 21-year-old geology student said: “I wish I understood what I’ve done”. He maintains he has no memory at all of the incident.

Mr McGregor pleaded guilty to a charge of behaving in a threatening or abusive manner.

Mr Douglas Williams, defending, referred to the events as “a bizarre incident which represented totally extraordinary behaviour which was totally out of character”. He claimed the archaic language used by Mr McGregor was “indicative of the accused’s inebriation and intoxication”.

The sitting sheriff was told that Mr McGregor had shown total remorse for his actions and had written a personal apology to Miss Cooper, expressing his regret and saying that he did not understand his own behaviour. Mr Williams also said that the report was very straightforward as his client had an impeccable record, had not been in trouble before and did not recognise anything about the unacceptable behaviour he had displayed.

Mr Williams submitted two written character references for Mr McGregor – one from a close personal friend of the defendant and one from a University professor.

Mr McGregor was sentenced to 140 hours of unpaid work and ordered to pay Ms Cooper damages of £400.

Handing down the court order, Sheriff William Wood said he accepted that while the crime was very serious, the behaviour was out of character and part of “high jinks”. However, he commented: “[Mr McGregor] should have moderated his behaviour when the police arrived. This was a very serious matter and very bizarre.

“Young training officers do engage in high jinks but at some point the game has to stop.”

It is not known whether Mr McGregor will face disciplinary procedures from the University or the OTC. The University of St Andrews declined to comment on the incident.