We assessed risk factors for human immunodeficiency virus (HIV) infection in 633 heterosexual intravenous drug users. The HIV seroprevalence was 26% in blacks, 10% in Hispanics, and 6% in whites. Intravenous cocaine use significantly increased the risk of HIV infection, with a seroprevalence of 35% in daily cocaine users (odds ratio, 6.4; 95% confidence interval, 3.0 to 13.3). Black subjects were more likely to use cocaine regularly. Drug use in shooting galleries and sharing of drug injection equipment were also associated with HIV infection and were more common in cocaine users. By multivariate analysis, black race, daily cocaine injection by blacks and Hispanics, all other cocaine injection, heavy use prior to entry into methadone treatment by blacks, and use of drugs in shooting galleries were independent predictors of HIV infection. Methadone therapy was associated with substantial reductions in heroin use and some reduction in cocaine use, but 24% of cocaine users receiving methadone began or increased cocaine injection after entry into treatment.