Obesity and type 2 diabetes mellitus (T2DM) are increasing in prevalence owing to decreases in physical activity levels and a shift to diets that include addictive and/or high-calorie foods. These changes are associated with the adoption of modern lifestyles and the presence of an obesogenic environment, which have resulted in alterations to metabolism, adaptive immunity and endocrine regulation. The size and quality of adipose tissue depots in obesity, including the adipose tissue immune compartment, are critical determinants of overall health. In obesity, chronic low-grade inflammation can occur in adipose tissue that can progress to systemic inflammation; this inflammation contributes to the development of insulin resistance, T2DM and other comorbidities. An improved understanding of adaptive immune cell dysregulation that occurs during obesity and its associated metabolic comorbidities, with an appreciation of sex differences, will be critical for repurposing or developing immunomodulatory therapies to treat obesity and/or T2DM-associated inflammation. This Review critically discusses how activation and metabolic reprogramming of lymphocytes, that is, T cells and B cells, triggers the onset, development and progression of obesity and T2DM. We also consider the role of immunity in under-appreciated comorbidities of obesity and/or T2DM, such as oral cavity inflammation, neuroinflammation in Alzheimer disease and gut microbiome dysbiosis. Finally, we discuss previous clinical trials of anti-inflammatory medications in T2DM and consider the path forward.