ABSTRACT: Use of addictive substances often creates powerful and enduring associations with external cues that act as relapse triggers in individuals recovering from a substance use disorder (SUD). In the reward-associated brain region, the nucleus accumbens (NAc), drug use or drug-associated cue exposure activates a subset of D1 dopamine receptor-expressing medium spiny neurons (D1-MSNs), which typically promotes drug seeking, and a smaller subset of D2 dopamine receptor-expressing MSNs (D2-MSNs), which typically opposes drug seeking. The activity-regulated transcription factor, Neuronal PAS Domain Protein 4 (NPAS4), is activated in a small subset of NAc neurons during cocaine conditioning, and NAc NPAS4 is required for drug-context memories. Using a new Npas4-TRAP mouse combined with chemogenetics, we found that the during cocaine conditioning, the NPAS4-positive ensemble is required for drug-context associations. Single-cell transcriptomic analyses and in situ hybridization of NAc tissues from drug-conditioned mice revealed that NPAS4 is expressed predominantly in MSNs, and using cell type-specific molecular genetic approaches, we found that NPAS4 in D2-MSNs, but not D1-MSNs, was required for both drug-context associations and cue-reinstated cocaine seeking. Similarly, NPAS4 in NAc D2-MSNs, but not D1-MSNs, blocked cocaine experience-dependent strengthening of glutamatergic prefrontal cortical (PFC) inputs onto D2-MSNs. Analysis of differential gene expression in D2-MSNs revealed that NPAS4 and cocaine conditioning influence a gene expression program associated with synapses, dendrites, neuronal projections, dopamine, and cocaine. Together, our data reveal that NPAS4 functions during active cocaine use to maintain the imbalance of D1-MSN:D2-MSN activation and cue-induced drug seeking by suppressing excitatory drive onto relapse-opposing NAc D2-MSN circuits.