BUFFALO — A 29-year-old Buffalo man was sentenced this week to 13 years in prison plus three years of post-release supervision after pleading guilty to two counts of third-degree criminal sale of a controlled substance for selling the powerful painkiller fentanyl.

While awaiting sentencing on that August guilty plea, Robert Smith was arrested and charged with possessing heroin, for which he also pleaded guilty to fourth-degree criminal possession of a controlled substance on Nov. 10.

Prosecutors say that on Jan. 26 and Feb. 8, Smith sold fentanyl to an undercover officer from the New York State Police. Based on the undercover fentanyl sales, the New York State Police obtained a search warrant for the defendant’s residence at 118 Gillette St. The police recovered 159 packages of fentanyl, two scales, packaging materials and more than $6,400 cash.