During withdrawal from cocaine, calcium permeable-AMPA receptors (CP-AMPAR) progressively accumulate in nucleus accumbens (NAc) synapses, a phenomenon linked to behavioral sensitization and drug-seeking. Recently, it has been suggested that neuroimmune alterations might promote aberrant changes in synaptic plasticity, thus contributing to substance abuse-related behaviors. Here, we investigated the role of microglia in NAc neuroadaptations after withdrawal from cocaine-induced conditioned place preference (CPP). We depleted microglia using PLX5622-supplemented diet during cocaine withdrawal, and after the place preference test, we measured dendritic spine density and the presence of CP-AMPAR in the NAc shell. Microglia depletion prevented cocaine-induced changes in dendritic spines and CP-AMPAR accumulation. Furthermore, microglia depletion prevented conditioned hyperlocomotion without affecting drug-context associative memory. Microglia displayed fewer number of branches, resulting in a reduced arborization area and microglia control domain at late withdrawal. Our results suggest that microglia are necessary for the synaptic adaptations in NAc synapses during cocaine withdrawal and therefore represent a promising therapeutic target for relapse prevention.