Repeated cocaine use produces neuroadaptations that support drug craving and relapse in substance use disorders (SUDs). Powerful associations formed with drug-use environments can promote a return to active drug use in SUD patients, but the molecular mechanisms that control the formation of these prepotent drug-context associations remain unclear. In the rat intravenous cocaine self-administration (SA) model, we examined the role and regulation of histone deacetylase 5 (HDAC5) in the prelimbic (PrL) and infralimbic (IL) cortices in context-associated drug seeking. To this end, we employed viral molecular tools, chemogenetics, RNA-sequencing, electrophysiology, and immunohistochemistry. In the PrL, reduction of endogenous HDAC5 augmented context-associated, but not cue-or drug prime-reinstated cocaine seeking, whereas overexpression of HDAC5 in PrL, but not IL, reduced context-associated cocaine seeking, but it had no effects on sucrose seeking. In contrast, PrL HDAC5 overexpression following acquisition of cocaine SA had no effects on future cocaine seeking. We found that HDAC5 and cocaine SA altered the expression of numerous PrL genes, including many synapse-associated genes. HDAC5 significantly increased inhibitory synaptic transmission onto PrL deep-layer pyramidal neurons, and it reduced the induction of FOS-positive neurons in the cocaine SA environment. Our findings reveal an essential and selective role for PrL HDAC5 to limit associations formed in cocaine, but not sucrose, SA environments, and that it alters the PrL excitatory/inhibitory balance, possibly through epigenetic regulation of synaptic genes. These results further position HDAC5 as a key factor regulating reward-circuit neuroadaptations that underlie common relapse triggers in SUD.