Opioids attach to receptors in the brain, with three main effects; reduced respiration, euphoria, decreased pain. The more opioids ingested the more of an effect. The process of opioids binding to the opioid receptors can be thought of as a mechanical union, the better the fit the more the opioid effect.
Buprenorphine is different. It too binds to the receptors, however, without a perfect fit. As a result the buprenorphine tends to occupy the receptors without all of the opioid effects. The receptor is tricked into thinking it has been satisfied with opioids without producing the feeling of euphoria, and without causing respiratory depression. This, in turn, prevents that receptor from joining with full opioids; therefore if the patient uses heroin or painkillers, they will not be able to experience any additional effect. Buprenorphine tends to stay with the receptors, blocking them, much longer then opioids do. This stickiness, is what makes buprenorphine last so long, up to 3 days.