Long-term application of chemical fertilizer poses an environmental threat to belowground ecosystems. However, the impact of nitrogen (N) or phosphorus (P) fertilizers on soil biodiversity and the conditions of soil food web remains largely unknown. Soil nematodes are the most abundant multicellular soil animals and serve as excellent bioindicators of soil. Here, we investigated soil nematode communities and food web structure in a long-term experiment with different application rates of N and P fertilizers in northeast China. The application of N and P fertilizers increased the abundance of bacterivores but suppressed the abundance of omnivores and predators. The abundance of bacterivores exhibited an increasing trend, while that of omnivores and predators showed a decreasing trend with increasing rates of N and P fertilizers. Plant parasites displayed a decreasing trend in response to N fertilizer, but not to P fertilizer. N and P fertilizers also altered nematode functional guild composition, with N fertilizer increasing the abundance of Ba1, and P fertilizer increasing the abundance of Fu2 and Ba3. Nonmetric multidimensional scaling (NMDS) analysis revealed apparent successions of nematode communities from no fertilizer soils to high rates of N or P fertilizer soils at both the genus and functional guild levels. Furthermore, N and P fertilizers resulted in different nematode communities. In terms of nematode food web indices, N fertilizer increased the enrichment index (EI) but reduced the channel index (CI) and structure index (SI), whereas P fertilizer only reduced the SI value. High rates of N and P fertilizers increased the respired carbon of bacterivores but reduced the respired carbon of predators. Mantel tests revealed significant correlations between soil properties and the community composition of both fungivores and omnivores. Among all soil properties, available phosphorus (AP) had the greatest influence on the community structure of soil nematodes. Our findings indicate that N fertilizer has a powerful effect on nematode food web structure, while P fertilizer exerts a stronger effect on soil nematode community composition.