Participants will be randomly assigned, within gender, to one of four treatment conditions: 1) buprenorphine and counseling in prison, with referral for continued treatment at an OTP upon release; 2) buprenorphine and counseling in prison, with referral for continued treatment at a CHC upon release; 3) counseling only in prison, with referral for buprenorphine and counseling at a OTP upon release; and 4) counseling only in prison, with referral for buprenorphine and counseling at a CHC upon release. Participants will be assessed at study entry and at 1, 3, 6, and 12 months following their release from prison. Outcome measures include: treatment entry and retention in the community, heroin use, cocaine use, HIV infection, HIV-risk behaviors, criminal activity, and employment.