Background Atherogenic index of plasma (AIP) plays an important role in predicting the occurrence of cardiovascular events and metabolic diseases. However, the relationship between AIP and insulin resistance (IR) are limited and controversial. Therefore, we aimed to clarify the relationship of AIP with IR and type 2 diabetes (T2D). Methods This cross-sectional study Based on the data of the National Health and Nutrition Survey (NHANES) from 2009 to 2018. Weighted multivariate linear regression, weighted multivariate logistic regression, subgroup analysis, generalized additive model, smooth curve fitting and two-part logistic regression were adopted to reveal the relationship between AIP and IR, T2D and its risk markers. Results A total of 9,245 patients were enrolled. After adjusting the potential confounders, AIP was positively correlated with FBG [β = 0.85 (95%CI: 0.66, 1.05)], HbA1c [β = 0.48 (95%CI: 0.39, 0.58)], FSI [β = 47.74 (95%CI: 41.42, 54.07)] and HOMA-IR [β = 2.39 (95%CI: 1.97, 2.82)]. Overall, there was a significant positive association between the AIP and IR [OR = 15.80 (95%CI: 11.44, 21.80)] and T2D [OR = 7.18 (95%CI: 5.21, 9.917)]. However, there was a significant interaction in the gender subgroup (IR: P for interaction = 0.0135; T2D: P for interaction = 0.0024) and smoking subgroup (IR: P for interaction = 0.0130). A reverse L-shaped association was found between AIP and IR, with a turning point of 0.45. Before the turning point, the OR (95% CI) was 13.15 (10.45, 16.55). A J-shaped association was found between AIP and T2D, with a turning point of -0.47. Before the turning point, the OR (95%CI) was 5.39(4.21, 6.89). Conclusions This study indicated that AIP exhibited an positive correlation with the risk markers of T2D (FBG, HbA1c, FSI and HOMA-IR). AIP is related to the increased risk of IR, and this relationship follows a reverse L-shaped curve. AIP is related to the increased risk of T2D, and this relationship follows a J-shaped curve.