Common variable immunodeficiency (CVID) is the most common symptomatic primary immunodeficiency characterized by low immunoglobulin (Ig)G and IgA, and/or IgM. In addition to bacterial infections, a large subgroup has noninfectious inflammatory and autoimmune complications. We performed 16S ribosomal RNA-based profiling of stool samples in 44 CVID patients, 45 patients with inflammatory bowel disease (disease controls), and 263 healthy controls. We measured plasma lipopolysaccharide (LPS) and markers of immune cell activation (i.e., soluble (s) CD14 and sCD25) in an expanded cohort of 104 patients with CVID and in 30 healthy controls. We found a large shift in the microbiota of CVID patients characterized by a reduced within-individual bacterial diversity (alpha diversity, P<0.001) without obvious associations to antibiotics use. Plasma levels of both LPS (P=0.001) and sCD25 (P<0.0001) were elevated in CVID, correlating negatively with alpha diversity and positively with a dysbiosis index calculated from the taxonomic profile. Low alpha diversity and high dysbiosis index, LPS, and immune markers were most pronounced in the subgroup with inflammatory and autoimmune complications. Low level of IgA was associated with decreased alpha diversity, but not independently from sCD25 and LPS. Our findings suggest a link between immunodeficiency, systemic immune activation, LPS, and altered gut microbiota.