Epidemiological and clinical studies have indicated a higher risk of nonalcoholic fatty liver disease (NAFLD) and type 2 diabetes mellitus (T2DM), implying a potentially shared genetic etiology, which is still less explored. Genetic links between T2DM and NAFLD were assessed using linkage disequilibrium score regression and pleiotropic analysis under composite null hypothesis. European GWAS data have identified shared genes, whereas SNP-level pleiotropic analysis under composite null hypothesis has explored pleiotropic loci. generalized gene-set analysis of GWAS data determines pleiotropic pathways and tissue enrichment using eQTL mapping to identify associated genes. Mendelian randomization analysis was used to investigate the causal relationship between NAFLD and T2DM. Linkage disequilibrium score regression analysis revealed a strong genetic correlation between T2DM and NAFLD, and identified 24 pleiotropic loci. These single-nucleotide polymorphisms are primarily involved in biosynthetic regulation, RNA biosynthesis, and pancreatic development. generalized gene-set analysis of GWAS data analysis revealed significant enrichment in multiple brain tissues. Gene mapping using these 3 methods led to the identification of numerous pleiotropic genes, with differences observed in liver and kidney tissues. These genes were mainly enriched in pancreas, brain, and liver tissues. The Mendelian randomization method indicated a significantly positive unidirectional causal relationship between T2DM and NAFLD. Our study identified a shared genetic structure between NAFLD and T2DM, providing new insights into the genetic pathogenesis and mechanisms of NAFLD and T2DM comorbidities.