The brain is the target of intense scientific study, yet currently there is no theory of how it works at the system level. In this talk I will present the first such theory. The theory is biological and concrete, showing how motor and cognitive capacities arise from relatively understood biological entities. The main idea is that brain function is managed by a response (R) process whose structure is very similar to the process guiding the immune system. The brain has two instances of the R process, managing execution and need satisfaction. The stages of the execution process are implemented by different neural circuits, explaining the roles of cortical layers, the different types of inhibitory interneurons, hippocampal fields and basal ganglia paths. The stages of the need process are supported by different molecular agents, explaining the roles of dopamine, serotonin, ACh, opioids and oxytocin. The same execution process gives rise to hierarchical motor sequences, language, and imagery, while the need process explains feelings/emotions and consciousness in a mechanistic manner. The theory includes some aspects that are dramatically different from accepted accounts, e.g., the roles of basal ganglia paths, serotonin and opioids. The scope of the addressed phenomena is large, but they are all explained quite simply by the R process.