To investigate the association between urinary lead and nonalcoholic fatty liver disease (NAFLD) . Methods The participants, aged ≥18 years, were selected from the 2017—2020 National Health and Nutrition Examination Survey (NHANES), with the exclusion of the participants with a lack of liver transient elastography data and urinary lead markers and those with hepatitis B, hepatitis C, and significant alcohol consumption. A total of 2 492 participants were enrolled and divided into NAFLD group with 852 participants and non-NAFLD group with 1 640 participants. High-performance liquid chromatographyelectrospray ionization-tandem mass spectrometry and online solid-phase extraction combined with isotope dilution were used to measure urinary lead level. The independent-samples t test or the Wilcoxon rank sum test was used for comparison of continuous data between two groups, and the chi-square test or the Fisher’s exact test was used for comparison of categorical data between two groups. Multivariate Logistic regression analysis, restricted cubic spline, subgroup analysis, and interaction analysis were used to investigate the association between urinary lead and NAFLD. Results The NAFLD group had a significantly higher urinary lead level than the non-NAFLD group (Z= − 2.023,P=0.043) . After adjustment of the covariates of age, sex, race, marital status, education, family income-to-poverty ratio, body mass index, smoking, drinking, diabetes mellitus, hypertension, and hyperlipidemia,there was a significant increase in the risk of NAFLD in the Q3 urinary lead group (odds ratio [OR] =1.360,95% confidence interval [CI] :1.019—1.817,P=0.037) . There was a positive dose-response relationship between urinary lead and the risk of NAFLD (P=0.047), which was a non-linear relationship (Pnon-linear=0.037) . There was a significant interaction between urinary lead and race, and for every quartile increase in urinary lead, the risk of NAFLD in Mexican-Americans was increased by 32.40% (OR= 1.324,95%CI:1.017—1.632,P<0.05) . Conclusion Urinary lead level is significantly associated with the risk of NAFLD. [ABSTRACT FROM AUTHOR]