Susceptibility to many human autoimmune diseases is under strong genetic control by class II human leukocyte antigen (HLA) allele combinations. These genes remain by far the greatest risk factors in the development of type 1 diabetes and celiac disease. Despite this, little is known about HLA influences on the composition of the human gut microbiome, a potential source of environmental influence on disease. Here, using a general population cohort from the All Babies in Southeast Sweden study, we report that genetic risk for developing type 1 diabetes autoimmunity is associated with distinct changes in the gut microbiome. Both the core microbiome and beta diversity differ with HLA risk group and genotype. In addition, protective HLA haplotypes are associated with bacterial genera Intestinibacter and Romboutsia. Thus, general population cohorts are valuable in identifying potential environmental triggers or protective factors for autoimmune diseases that may otherwise be masked by strong genetic control.