The genes encoding antigen receptors are unique because of their high diversity and their assembly in developing lymphocytes from gene segments through a series of site-specific DNA recombination reactions known as V(D)J rearrangement. This review focuses on our understanding of how recombination of immunoglobulin and T-cell receptor gene segments is tightly regulated despite being catalysed by a common lymphoid recombinase, which recognizes a widely distributed conserved recombination signal sequence. Probable mechanisms involve precise expression of the lymphoid-restricted recombination-activating genes RAG1 and RAG2, and developmentally regulated epigenetic alterations in template accessibility, which are targeted by transcriptional regulatory elements and involve chromatin-modifying enzymes.