Memory and the expression of learned behaviors by an organism are often triggered by contextual cues that resemble those that were present when the initial learning occurred. In state-dependent learning, the cue eliciting a learned behavior is a neuroactive drug; behaviors initially learned during exposure to centrally acting compounds such as ethanol are subsequently recalled better if the drug stimulus is again present during testing. Although state-dependent learning is well documented in many vertebrate systems, the molecular mechanisms underlying state-dependent learning and other forms of contextual learning are not understood. Here we demonstrate and present a genetic analysis of state- dependent adaptation in Caenorhabditis elegans. C. elegans normally exhibits adaptation, or reduced behavioral response, to an olfactory stimulus after prior exposure to the stimulus. If the adaptation to the olfactory stimulus is acquired during ethanol administration, the adaptation is subsequently displayed only if the ethanol stimulus is again present. cat-1 and cat-2 mutant animals are defective in dopaminergic neuron signaling and are impaired in state dependency, indicating that dopamine functions in state-dependent adaptation in C. elegans.