The adaptive immune system arose 500 million years ago in ectothermic (cold-blooded) vertebrates. Classically, the adaptive immune system has been defined by the presence of lymphocytes expressing recombination-activating gene (RAG)-dependent antigen receptors and the MHC. These features are found in all jawed vertebrates, including cartilaginous and bony fish, amphibians and reptiles and are most likely also found in the oldest class of jawed vertebrates, the extinct placoderms. However, with the discovery of an adaptive immune system in jawless fish based on an entirely different set of antigen receptors — the variable lymphocyte receptors — the divergence of T and B cells, and perhaps innate-like lymphocytes, goes back to the origin of all vertebrates. This Review explores how recent developments in comparative immunology have furthered our understanding of the origins and function of the adaptive immune system.