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 strong feelings of euphoria, and without causing significant respiratory depression. This, in turn, prevents that receptor from joining with full opioids; therefore if the patient uses heroin or painkillers, they are unlikely to experience 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.