A police hunt for anthrax-contaminated heroin found a man who provided a safehouse for drugs with a street value of nearly £250,000, a court has heard.
Bruce Kirkpatrick, 37, of Lochside Road, Dumfries, admitted being concerned in supplying the drug in his home town between June and August 2009.
Judge Lord Menzies told him he had a bad record and previous offences.
He said the drugs involved had a "relatively high street value" and jailed him for 39 months.
The judge told him: "I take account of the fact that you made no monetary gain from your involvement with the drugs and participated to feed your own drug habit."
Lord Menzies said he also took into account that Kirkpatrick was "at the lower end of the hierarchy of drug dealing" with several people more senior to him in the supply chain.
The judge told him at the High Court in Edinburgh he would have faced a six year prison sentence, but it would be reduced following his guilty plea and other factors in his favour.
The court heard that unemployed heroin user Kirkpatrick was detained in April this year.
It followed a number of confirmed cases of anthrax linked to injecting heroin in Dumfries and Galloway.
Advocate depute Gillian More said: "Police commenced investigations in an effort to identify the supply chain for the contaminated heroin locally by identifying those involved in the supply and distribution of heroin."
Raids were carried out and arrests made and intelligence provided by undercover officers in helping to identify those involved in selling potential contaminated heroin in Dumfries.
The prosecutor said the police operation uncovered a Liverpool connection.
Houses in Lochside Road where Kirkpatrick and his girlfriend were tenants were searched and mobile phones recovered along with notebooks, a diary and address book.
Kirkpatrick at first denied any involvement in the supply of heroin, but later admitted keeping drugs for other people.
Police calculated that the amount of the drug involved had the potential to realise £245,000 on the streets.
Defence solicitor advocate Bill McVicar said Kirkpatrick had been affected by drug abuse since his teenage years.
He added: "He was a user of heroin and his involvement came about because of that.
"He is not a man who was making any profit from what he was doing."