Use of addictive substances creates powerful drug-cue associations that often trigger relapse. Drug seeking is gated in the nucleus accumbens (NAc) by competing activation of D1 dopamine receptor-expressing medium spiny neurons (D1-MSNs) that promote, and D2 dopamine receptor-expressing neurons (D2-MSNs) that oppose, drug seeking. We show here that the ensemble of neurons in the NAc that induce the neuronal activity-regulated transcription factor, Neuronal PAS Domain Protein 4 (NPAS4), is required for cocaine-context associations. In addition, NPAS4 functions within NAc D2-MSNs to govern the activation balance of NAc D1-MSNs and D2-MSNs necessary for drug-context memories and cue-induced cocaine, but not sucrose, seeking. NPAS4 regulates drug-cue associations and preponderant D1-MSN activation by influencing a program of gene expression that blocks cocaine-induced potentiation of prefrontal cortical excitatory drive onto D2-MSNs. Together our findings reveal that NPAS4 is a key player governing NAc MSN cell-type activation balance and promoting drug-cue associations and relapse vulnerability.