The gut microbiota structure, dynamics, and function result from interactions with environmental and host factors, which jointly influence the communication between the gut and peripheral tissues, thereby contributing to health programming and disease risk. Incidence of both type-1 and type-2 diabetes has increased during the past decades, suggesting that there have been changes in the interactions between predisposing genetic and environmental factors. Animal studies show that gut microbiota and its genome (microbiome) influence alterations in energy balance (increased energy harvest) and immunity (inflammation and autoimmunity), leading to metabolic dysfunction (e.g., insulin resistance and deficiency). Thus, although they have different origins, both disorders are linked by the association of the gut microbiota with the immune-metabolic axis. Human studies have also revealed shifts in microbiome signatures in diseased subjects as compared with controls, and a few of them precede the development of these disorders. These studies contribute to pinpointing specific microbiome components and functions (e.g., butyrate-producing bacteria) that can protect against both disorders. These could exert protective roles by strengthening gut barrier function and regulating inflammation, as alterations in these are a pathophysiological feature of both disorders, constituting common targets for future preventive approaches.