Cognitive deficits are long-lasting consequences of drug use, yet the convergent mechanism by which classes of drugs with different pharmacological properties cause similar deficits is unclear. We find that both phencyclidine and methamphetamine, despite differing in their targets in the brain, cause the same glutamatergic neurons in the medial prefrontal cortex of male mice to gain a GABAergic phenotype and decrease expression of their glutamatergic phenotype. Suppressing drug-induced gain of GABA with RNA-interference prevents appearance of memory deficits. Stimulation of dopaminergic neurons in the ventral tegmental area is necessary and sufficient to produce this gain of GABA. Drug-induced prefrontal hyperactivity drives this change in transmitter identity. Returning prefrontal activity to baseline, chemogenetically or with clozapine, reverses the change in transmitter phenotype and rescues the associated memory deficits. This work reveals a shared and reversible mechanism that regulates the appearance of cognitive deficits upon exposure to different drugs.