Steven Frater, 32, hid 167 diazepam tablets and quantities of heroin and oxymetholene inside his body.
He then stole a television from the Asda store in Galashiels, hoping to be arrested and sent to Edinburgh Prison.
Frater, formerly of Jedburgh, admitted at Selkirk Sheriff Court the theft and refusing an internal examination at Edinburgh Royal Infirmary in February.
The court heard he attempted to defeat the ends of justice by refusing to be examined in hospital knowing he had the controlled drugs inside his body.
However, he was subsequently found to have swallowed a number of substances that he had hoped to distribute in jail.
Sheriff Jamie Gilmour sentenced him to three years in prison for the offences.
A man who swallowed a large quantity of drugs in order to smuggle them into prison has been jailed for three years.