Christopher Deans was waiting to give evidence in a criminal trial at Haddington Sheriff Court last month but went home before he was called.
When it was discovered Deans, 28, had left the court building a warrant was issued for his arrest and he appeared in the dock charged with contempt of court the following day.
Unemployed Deans, from Dunbar, East Lothian, said he had gone home early after being told there was "something wrong with the fire alarms" in the court building, but no evidence could be produced to back up his story.
Defence solicitor Colm Dempsey admitted to the court his client's actions were a serious matter and that Deans "apologises profusely" for his early departure from the trial on December 6.
But Sheriff Peter Braid told Deans he had "not been honest" in his dealings with the court and sentenced the father-of-two to 14 days in prison.
Sheriff Braid said: "Witnesses not turning up for trials is an increasing problem. You chose to go home at lunchtime and that was a contempt of court."
The postponed trial, involving brothers Keith and Steven Millar, who were charged with weapon possession, went ahead the following week.
Both accused were found not guilty.