One of the enduring mysteries of brain function concerns the process of cognitive control. How does complex and seemingly willful behaviour emerge from interactions between millions of neurons? This has long been suspected to depend on the prefrontal cortex--the neocortex at the anterior end of the brain--but now we are beginning to uncover its neural basis. Nearly all intended behaviour is learned and so depends on a cognitive system that can acquire and implement the 'rules of the game' needed to achieve a given goal in a given situation. Studies indicate that the prefrontal cortex is central in this process. It provides an infrastructure for synthesizing a diverse range of information that lays the foundation for the complex forms of behaviour observed in primates.