A healthy individual can mount an immune response to exogenous pathogens while avoiding an autoimmune attack on normal tissues. The ability to distinguish between self and non-self is called 'immunological tolerance' and, for T lymphocytes, involves the generation of a diverse pool of functional T cells through positive selection and the removal of overtly self-reactive thymocytes by negative selection during T-cell ontogeny. To elucidate how thymocytes arrive at these cell fate decisions, here we have identified ligands that define an extremely narrow gap spanning the threshold that distinguishes positive from negative selection. We show that, at the selection threshold, a small increase in ligand affinity for the T-cell antigen receptor leads to a marked change in the activation and subcellular localization of Ras and mitogen-activated protein kinase (MAPK) signalling intermediates and the induction of negative selection. The ability to compartmentalize signalling molecules differentially in the cell endows the thymocyte with the ability to convert a small change in analogue input (affinity) into a digital output (positive versus negative selection) and provides the basis for establishing central tolerance.