The incidence of fatal overdoses has increased worldwide due to the widespread access to illicit fentanyl and its potent analogues. Vaccines offer a promising strategy to reduce the prevalence of opioid use disorders (OUDs) and to prevent toxicity from accidental and deliberate exposure to fentanyl and its derivatives. This study describes the development and characterization of vaccine formulations consisting of novel fentanyl-based haptens conjugated to carrier proteins. Vaccine efficacy was tested against opioid-induced behavior and toxicity in mice and rats challenged with fentanyl and its analogues. Prophylactic vaccination reduced fentanyl- and sufentanil-induced antinociception, respiratory depression, and bradycardia in mice and rats. Therapeutic vaccination also reduced fentanyl intravenous self-administration in rats. Because of their selectivity, vaccines did not interfere with the pharmacological effects of commonly used anesthetics nor with methadone, naloxone, oxycodone, or heroin. These preclinical data support the translation of vaccines as a viable strategy to counteract fentanyl use disorders and toxicity.