The relationship between the accumulation of fat in visceral or subcutaneous tissue and bone mineral density (BMD) remains unclear. Our primary objective in this study was to illuminate this relationship by conducting an investigation on a vast scale, encompassing a nationally representative population in the United States. A weighted multiple linear regression model was established to evaluate the relationship between visceral fat, subcutaneous fat, and BMD. Additionally, the exploration of the potential nonlinear relationship was conducted employing the methodology of smooth curve fitting. In order to determine potential inflection points, a two-stage linear regression model was utilized. A total of 10,455 participants between the ages of 20 and 59 were included in this study. Various weighted multiple linear regression models revealed a negative correlation between lumbar BMD and visceral mass index (VMI) and subcutaneous mass index (SMI). However, the association between VMI and lumbar BMD displayed a U-shaped pattern upon employing the smooth curve fitting, and the inflection point of 0.304 kg/m2was determined using a two-stage linear regression model. Our findings indicated a negative association between subcutaneous fat and BMD. A U-shaped relationship was observed between visceral fat and BMD.