Drug addicts have deficits in frontocortical function and cognition even long after the discontinuation of drug use. It is not clear, however, whether the cognitive deficits are a consequence of drug use, or are present prior to drug use, and thus are a potential predisposing factor for addiction. To determine if self-administration of cocaine is capable of producing long-lasting alterations in cognition, rats were allowed access to cocaine for either 1 h/day (short access, ShA) or 6 h/day (long access, LgA) for 3 weeks. Between 1 and 30 days after the last self-administration session, we examined performance on a cognitively demanding test of sustained attention that requires an intact medial prefrontal cortex. The expression levels of dopamine D1 and D2 receptor mRNA and D2 protein in the prefrontal cortex were also examined. Early after discontinuation of drug use, LgA (but not ShA) animals were markedly impaired on the sustained attention task. Although the LgA animals improved over time, they continued to show a persistent pattern of performance deficits indicative of a disruption of cognitive flexibility up to 30 days after the discontinuation of drug use. This was accompanied by a significant decrease in DA D2 (but not D1) mRNA in the medial and orbital prefrontal cortex, and D2 receptor protein in the medial prefrontal cortex of LgA (but not ShA) animals. These findings establish that repeated cocaine use is capable of producing persistent alterations in the prefrontal cortex and in cognitive function, and illustrate the usefulness of extended access self-administration procedures for studying the neurobiology of addiction.