Cocaine-induced alterations in gene expression cause changes in neuronal morphology and behavior that may underlie cocaine addiction. In mice, we identified an essential role for histone 3 lysine 9 (H3K9) dimethylation and the lysine dimethyltransferase G9a in cocaine-induced structural and behavioral plasticity. Repeated cocaine administration reduced global levels of H3K9 dimethylation in the nucleus accumbens. This reduction in histone methylation was mediated through the repression of G9a in this brain region, which was regulated by the cocaine-induced transcription factor DeltaFosB. Using conditional mutagenesis and viral-mediated gene transfer, we found that G9a down-regulation increased the dendritic spine plasticity of nucleus accumbens neurons and enhanced the preference for cocaine, thereby establishing a crucial role for histone methylation in the long-term actions of cocaine.