Fentanyl is an extremely potent synthetic opioid that has been increasingly used to adulterate heroin, cocaine, and counterfeit prescription pills, leading to an increase in opioid-induced fatal overdoses in the United States, Canada, and Europe. A vaccine targeting fentanyl could offer protection against the toxic effects of fentanyl in both recreational drug users and others in professions at risk of accidental exposure. This study focuses on the development of a vaccine consisting of a fentanyl-based hapten (F) conjugated to keyhole limpet hemocyanin (KLH) carrier protein or to GMP-grade subunit KLH (sKLH). Immunization with F-KLH in mice and rats reduced fentanyl-induced hotplate antinociception, and in rats reduced fentanyl distribution to the brain compared with controls. F-KLH did not reduce the antinociceptive effects of equianalgesic doses of heroin or oxycodone in rats. To assess the vaccine effect on fentanyl toxicity, rats immunized with F-sKLH or unconjugated sKLH were exposed to increasing subcutaneous doses of fentanyl. Vaccination with F-sKLH shifted the dose-response curves to the right for both fentanyl-induced antinociception and respiratory depression. Naloxone reversed fentanyl effects in both groups, showing that its ability to reverse respiratory depression was preserved. These data demonstrate preclinical selectivity and efficacy of a fentanyl vaccine and suggest that vaccines may offer a therapeutic option in reducing fentanyl-induced side effects.