The primate basal ganglia are a collection of subcortical structures that have long been considered part of the extrapyramidal motor system, the part of the motor system concerned with automatic aspects of movement. Despite a large amount of data regarding their anatomy and physiology, the role of the basal ganglia in both action planning and decision making remains enigmatic. Anatomical labeling studies have suggested that the striatum receives projections from the cerebral cortex that coarsely preserves topography, and that the basal ganglia maintain a segregation of information streams (Goldman-Rakic and Selemon 1986;Hoover and Strick 1993;Parent 1990). We suggest that the connectivity of the basal ganglia is ideally suited to selecting optimal actions for given cognitive and sensory states. We demonstrate how a computational network of pools of neurons connected in the arrangement found in the basal ganglia can perform what we term a "winnerlose-all" function. The winner-lose-all mechanism refers to the fact that the neurons of the output stage of the basal ganglia, the internal segment of the globus pallidus (GPi), are tonically active and are inhibited when corresponding striatal afferents fire. Thus the GPi neuron that is selected is actually inhibited because it loses rather than wins the competition. Diffuse excitatory projections from the subthalamic nucleus prevent all but the winning pallidal neuron pool from being inhibited. Because the thalamic targets of the GPi projection in turn feed back to the approximate cortical area of the originating afferent, this cortical-subcortical loop is ideally suited not only for the aforementioned action-selection, but also for the generation of sequences appropriate for given cortical states. We demonstrate how the circuitry of the basal ganglia can learn to select the best action for different cortical states and how the feedback representation of the action-selection leads to the generation of sequences of actions.