Dad-of-one Jason Leary, 46, of no fixed abode, had attended HMP Lancaster Farms to visit a prisoner, but the dog showed an interest in him as visitors were screened walking into the visitors hall.
Prosecuting, Paul Cummings said staff continued to observe him via CCTV.
He added: “Towards the end of the visit he was seen fidgeting in his crotch area.
“At the end the prisoner was seen to open the front of his trousers. As the prisoner stood up it was seen the defendant passed an article to him.”
The inmate tried to run away but the package of spice and cannabis was found in his sock
His defence team said Leary, who admitted the offences, was under pressure from others to smuggle the item in, or could face harm.
Recorder Joanne Woodward sentenced him to 32 months in prison.