Young offenders hoping to delay their sentencing at Edinburgh Sheriff Court jammed the lock of their holding cell with sausage and chips.
The lock was jammed by a sausage supper
Reliance security staff were unable to open the door to the five person cell in the building's basement.
The male offenders, all under 21, were to be taken to various courtrooms for deferred sentencing on Monday.
The officers used water to dissolve the food from the lock and managed to get the men to court just in time.
A court insider said: "They were mucking about, but it will backfire on them because the next time they are here we will put them in a high security cell used to segregate prisoners. It has no bars and steel walls.
"And although I know the boys were just having a laugh there is a serious side to it as well.
"We had to free the lock as quickly as possible for health and safety reasons to protect their own safety in case there was a fire or one had a health problem."