Long-lasting, drug-induced adaptations within the nucleus accumbens (NAc) have been proposed to contribute to drug-mediated addictive behaviors. Here we have used an optogenetic approach to examine the role of NAc medium spiny neurons (MSNs) expressing dopamine D2 receptors (D2R) in cocaine-induced behavioral sensitization. Adeno-associated viral vectors coding channelrhodopsin-2 (ChR2) were delivered into the NAc of D2R-Cre transgenic mice. This allowed us to selectively photostimulate D2R-MSNs in NAc. D2RMSNs form local inhibitory circuits, because photostimulation of D2R-MSN evoked inhibitory postsynaptic currents in neighboring MSNs. Photostimulation of NAc D2R-MSN in vivo affected neither the initiation nor the expression of cocaine-induced behavioral sensitization. However, photostimulation during the drug withdrawal period attenuated expression of cocaine-induced behavioral sensitization. These results show that D2R-MSNs of NAc play a key role in withdrawal-induced plasticity and may contribute to relapse after cessation of drug abuse.