Neurophysiological studies have identified a number of brain regions critically involved in solving the problem of 'action selection' or 'decision making'. In the case of highly practiced tasks, these regions include cortical areas hypothesized to integrate evidence supporting alternative actions, and the basal ganglia, hypothesised to act as a central 'switch' in gating behavioural requests. However, despite our relatively detailed knowledge of basal ganglia biology and its connectivity with the cortex, and numerical simulation studies demonstrating selective function, no formal theoretical framework exists that supplies an algorithmic description of these circuits. This paper shows how many aspects of the anatomy and physiology of the circuit involving the cortex and basal ganglia are exactly those required to implement the computation defined by an asymptotically optimal statistical test for decision making - the Multiple Sequential Probability Ratio Test (MSPRT). The resulting model of basal ganglia provides a new framework for understanding the computation in the basal ganglia during decision making in highly practiced tasks. The predictions of the theory concerning the properties of particular neuronal populations are validated in existing experimental data. Further, we show that this neurobiologically grounded implementation of MSPRT outperforms other candidates for neural decision making, that it is structurally and parametrically robust, and that it can accommodate cortical mechanisms for decision making in a way which complements those in basal ganglia.