Obesity is a significant factor contributing to erectile dysfunction (ED). Early detection of ED generally results in improved treatment outcomes. Our study aims to elucidate the association between relative fat mass (RFM) and ED by analyzing data from the National Health and Nutrition Inspection Survey (NHANES) spanning 2001 to 2004. We used data from NHANES 2001-2004, employing weighted, multivariable-adjusted logistic regression to assess the relationship between RFM and the risk of ED. Additional analyses included subgroup analysis, smooth curve fitting, and threshold effect analysis. Subsequently, the predictive utility of RFM, body mass index (BMI), and waist circumference (WC) for ED was evaluated using the receiver operating characteristic curve and area under the curve (AUC) calculations. A total of 3,947 American male participants were included in this retrospective study within NHANES. Weighted multivariate logistic regression analysis indicated that, after adjusting for potential confounding factors, RFM was positively associated with the risk of ED (OR = 1.03, 95% CI = 1.01-1.05,