The kidneys are frequently targeted by pathogenic immune responses against renal autoantigens or by local manifestations of systemic autoimmunity. Recent studies in rodent models and humans have uncovered several underlying mechanisms that can be used to explain the previously enigmatic immunopathology of many kidney diseases. These mechanisms include kidney-specific damage-associated molecular patterns that cause sterile inflammation, the crosstalk between renal dendritic cells and T cells, the development of kidney-targeting autoantibodies and molecular mimicry with microbial pathogens. Conversely, kidney failure affects general immunity, causing intestinal barrier dysfunction, systemic inflammation and immunodeficiency that contribute to the morbidity and mortality of patients with kidney disease. In this Review, we summarize the recent findings regarding the interactions between the kidneys and the immune system.