Foraging- and feeding-related behaviors across eumetazoans share similar molecular mechanisms, suggesting the early evolution of an optimal foraging behavior called area-restricted search (ARS), involving mechanisms of dopamine and glutamate in the modulation of behavioral focus. Similar mechanisms in the vertebrate basal ganglia control motor behavior and cognition and reveal an evolutionary progression toward increasing internal connections between prefrontal cortex and striatum in moving from amphibian to primate. The basal ganglia in higher vertebrates show the ability to transfer dopaminergic activity from unconditioned stimuli to conditioned stimuli. The evolutionary role of dopamine in the modulation of goal-directed behavior and cognition is further supported by pathologies of human goal-directed cognition, which have motor and cognitive dysfunction and organize themselves, with respect to dopaminergic activity, along the gradient described by ARS, from perseverative to unfocused. The evidence strongly supports the evolution of goal-directed cognition out of mechanisms initially in control of spatial foraging but, through increasing cortical connections, eventually used to forage for information.