Soil nitrogen in farmland ecosystems is affected by climate, soil physical and chemical properties and planting activities. To clarify the effects of these factors on soil nitrogen in sloping farmland quantitatively, the distribution of soil total nitrogen (TN) content, nitrate nitrogen (NO3-N) content and ammonium nitrogen (NH4-N) content at depth of 0–100 cm on 11 profiles of the Luanhe River Basin were analyzed. Meanwhile, soil physical and chemical properties, climatic factors and NDVI (Normalized Difference Vegetation Index) were used to construct a structural equation which reflected the influence mechanism of environmental factors on soil nitrogen concentration. The results showed that TN and NO3-N content decreased with the increase of soil depth in the Luanhe River Basin, while the variation of NH4-N content with soil depth was not obvious. Soil organic carbon (SOC) content, soil pH, soil area average particle size (SMD) and NDVI6 (NDVI of June) explained variation of TN content by 77.4%. SOC was the most important environmental factor contributing to the variation of TN content. NDVI5 (NDVI of May), annual average precipitation (MAP), soil pH and SOC explained 49.1% variation of NO3-N content. Among all environmental factors, only NDVI8 (NDVI of August) had significant correlation with soil NH4-N content, which explained the change of NH4-N content by 24.2%. The results showed that soil nitrogen content in the sloping farmland ecosystem was mainly affected by natural factors such as soil parent material and climate.