A prison officer sparked chaos at a jail by waving a Union flag in front of inmates.
Stuart Richardson held the flag aloft on a pole days after he also had it tied around his neck at HMP Low Moss in Bishopbriggs.
One colleague describe raging prisoners being "very angry" amid fears Richardson could have caused a fight.
The 33 year-old pleaded guilty at Glasgow Sheriff Court this week to acting in a threatening and abusive manner between June 29 and July 1 2022.
The claims that he had made sectarian remarks and that the offence was aggravated by religious prejudice were deleted by prosecutors.
Richardson's lawyer stated that the now ex-guard had been "absolutely stupid" and his lost his job of three years as a result.
Richardson, of Bearsden, will be sentenced in the New Year.
He had originally gone on trial before his guilty plea was accepted.
Former prison worker Vincent Stewart gave evidence.
He first recalled a day that he could hear inmates "having a laugh" at the jail's waste management area.
Mr Stewart said: "I saw Stuart coming through the door with the Union flag tied around his neck carrying on with the other boys."
Fiscal Leo McGinn asked if anything was said at the time.
Mr Stewart replied: "There was a bit of carry on with the other boys.
"Someone said 'Get the flag out, the prisoners are coming down' and Stuart replied 'it's my flag, it's my country'."
CCTV was also shown to the court where Richardson was seen to fly the flag from a pole.
The hearing was told that Richardson was again seen with the Union flag days later.
Mr Stewart said: "I was sitting in the office - you can see the prisoners day area.
"I saw a commotion going on and I could see Stuart coming through the back door with a Union flag on a pole.
"He made his way through to the day area and prisoners were all reacting to it.
"Stuart left through the back door and a few prisoners came into the office."
Mr McGinn asked: "Could you see him doing anything with the flag?"
Mr Stewart said: "He was waving it above his shoulders."
Mr McGinn asked: "Could you hear any reaction from the prisoners?|
The witness said: "Yes, very angry, they were shouting - some tried to jump off tables in the day area to get to the door.
"I thought s***, something serious has happened - I was looking to see if there had been a fight in the day area."
After the plea was accepted, Judith Hutchison, defending, told the court: "He always accepted his behaviour that day.
"He was a prison officer and had been for about three years - he accepts the position in respect of the flag."
Sentence was deferred pending background reports until February by Sheriff Andrew Cubie.
Richardson was bailed meantime.
The sheriff said: "You pled guilty and you will be given credit for that. I want more background before giving the appropriate penalty.
"I take account that this conduct has resulted in the loss of your job."