Dyslipidemia and inflammation often coexist in the progression of kidney failure, with the atherosclerosis index of plasma (AIP) serving as a valuable marker for monitoring dyslipidemia. This cross-sectional study analyzed data from the National Health and Nutrition Examination Survey (NHANES) spanning 2005 to 2018, involving a total of 10,358 participants. AIP was calculated as the logarithmic ratio (base 10) of triglycerides to high-density lipoprotein cholesterol (log10[TG/HDL-C]), while kidney failure was assessed through self-reported physician diagnosis. Logistic regression models and restricted cubic splines (RCS) were utilized to examine the association between AIP and the risk of kidney failure, with additional subgroup analyses performed to explore potential interactions. Mediation analyses were conducted to investigate whether inflammatory markers mediated the relationship between AIP and kidney failure. In logistic regression, after adjusting for all covariates, AIP was found to be positively associated with the risk of kidney failure [OR = 1.74 (95% CI: 1.04-2.92)], and a linear relationship between AIP and kidney failure risk was observed (P-non-linear = 0.4050). Mediation analysis revealed that segmented neutrophils, eosinophils, and monocytes partially mediated the association between AIP and kidney failure, with mediation proportions of 19.65%, 2.44%, and 7.25%, respectively. These findings suggest that Higher AIP was associated with an increased risk of kidney failure, with segmented neutrophils, eosinophils, and monocytes serving as partial mediators. The results provide valuable insights into the role of inflammation in kidney failure and highlight potential avenues for its prevention.