Perth Sheriff Court was told Ryan McAusland was due to be released from a four year jail term today.
But instead he was sent back to prison for a further six months after he admitted trying to take a Blackberry phone into Castle Huntly prison.
McAusland, 23, from Glasgow, was caught acting in a furtive manner when he tried to sneak the phone in.
Fiscal depute Robbie Brown told the court: "The accused had returned from a home leave visit.
"He was asked if he had anything in his possession and he said no.
"When officers searched his bag he appeared nervous and they asked him again. He then handed over a Blackberry phone."
McAusland's solicitor told the court his client had already been allowed out for four home visits and had not caused any problems during those periods of leave.
He said: "He had his phone with him when he returned and he should have left it outside. He didn't realise he had it with him.
"The tragedy is that this was his first conviction which led to a period of imprisonment and he was due to be released from his sentence tomorrow."
But Sheriff Richard McFarlane pointed out that McAusland lied to the prison officers about the phone.
"Your trust with the authorities got to the stage where you were relocated to Castle Huntly and given the privilege of home leave," Sheriff McFarlane said.
"These items are regarded as high value currency within the prison world.
"They do cause considerable disruption with regard to order in the prison on a day to day basis.
"That is a significant aspect and one I cannot ignore in the public interest"
McAusland, who was serving four years for assault imposed at Glasgow High Court in February 2011, had six months added to his sentence.