Urban rivers are hotspots for atmospheric CH4 and CO2 emissions. Monitoring their fluxes is of great significance for understanding the carbon cycle process disrupted by human activities and assessing the carbon budget of river basins. The emissions of greenhouse gases from natural rivers have been widely studied, but the impact of urbanization and land use changes caused by human activities on the distribution pattern of carbon fluxes in rivers around cities is still not fully understood. To bridge this knowledge gap, this study set up 14 sampling points with a total of 28 samples. By using the static flux chamber method, the fluxes of CH4 and CO2 in the Fen River, a tributary of the Yellow River, were determined, and the relevant physical and chemical indicators of the water body were monitored simultaneously. The results showed that both gases were in a supersaturated state, and the average values of FCH4 and FCO2 reached 1005.53 ± 459.16 μmol·m−2·d−1 and 289.75 ± 176.45 mmol·m−2·d−1, respectively. The FCH4 of Wet month was 1.4 times that of Dry month, and the FCO2 of Wet month was 2.4 times that of Dry month. The ratio of built-up area respectively explained 54% and 31% of the spatial variations of FCH4 and FCO2. The structural equation model indicates that the standardized direct effects of urbanization on FCH4 and FCO2 were 0.21 and 0.23 respectively, while the standardized indirect effects through physical and chemical indicators of water bodies (TP, DOC, NH4+ and EC) were 0.47 and 0.40 respectively. Thus, nutrient inputs became the primary drivers for the increase in FCH4 and FCO2. This study suggests that FCH4 and FCO2 in river sections near urban areas are more sensitive to land-use changes and water pollution. Land use and urbanization indirectly affect riverine FCH4 and FCO2 by altering nutrient inputs. These findings underscore that FCH4 and FCO2 in river segments near urban areas are more sensitive to changes in land use and water pollution. Land use and urbanization indirectly influence riverine FCH4 and FCO2 by altering nutrient inputs. Such understanding is critical for future coordinated efforts aimed at pollution reduction and carbon mitigation along urban–rural river gradients, as well as for addressing the pressures of climate change.