The lodging issue is a significant factor that hinders the enhancement of oil flax production efficiency in northern China. Crop lodging or not, and lignin content in the stems are closely related, and how nitrogen fertilizer and potassium fertilization interaction regulate lignin biosynthesis in the stems of oil flax requires further in-depth study. Therefore, the research aims to enhance the lodging resistance and facilitate an increased yield of oil flax. We are examined the interaction of different nitrogen fertilizers (75, 150, and 225 kg N ha-1) and potassium fertilizers (60 and 90 kg K2O ha-1) on oil flax lignin metabolism, lodging resistance, and grain yield in 2022 and 2023 growing seasons. The results indicated that nitrogen and potassium fertilizer levels and their interaction treatments are facilitated lignin accumulation, achievement of lodging resistance and high yield. Compared to CK, the 75-150 kg N ha-1 in combination with 60 kg K2O ha-1 treatments significantly enhanced the enzyme activities (TAL, PAL, POD, and CAD) and the gene expressions (4CL1 and F5H3) for lignin syntheses, lignin content dramatically increased 29.63-43.30%, improved stem bending strength and lodging resistance index, and grain yield increased 23.27-32.34%. Correlation analysis indicated that nitrogen and potassium fertilizer positively regulated the relative enzyme activities and genes expression for lignin to facilitated lignin biosynthesis and accumulation, and enhanced stem bending strength and lodging resistance index. Positive correlations were found among the relative enzyme activities and gene expressions for lignin, lodging resistance and grain yield. To summarize, 75-150 kg N ha-1 in conjunction with 60 kg K2O ha-1 treatment was promoted to lignin biosynthesis and accumulation, enhanced the lodging resistance and grain yield of oil flax in the dryland farming region of central Gansu. Furthermore, it served as a technical guide for cultivating stress tolerance and high-yield oil flax in the dryland farming region.