Extended release of sufentanil is provided by implanting a device containing sufentanil into a mammal or human being. The device may include a solid biocompatible polymer matrix, and sufentanil may be encapsulated within the polymer matrix. The polymer matrix comprises a plurality of pores configured to allow contact between the sufentanil and a physiological fluid of a mammal into which the device is implanted to thereby release sufentanil in vivo from the device into the mammal. The devices may be used to treat opioid addiction or pain.