Promoting the sustainable development of agriculture is the basis of reducing the poverty rate, ensuring food security, and promoting common prosperity. In order to explore the impact of industrial capital and commercial capital on the sustainable development of agriculture, this paper starts from the perspective of agriculture and conducts empirical tests based on the panel data of 30 provinces in China (except Tibet) from 2013 to 2022, using the fixed-effect model and spatial spillover effect model. The results included the following: (1) industrial capital and commercial capital can significantly promote the sustainable development of agriculture, and this conclusion was still valid after endogenous test and robustness test; (2) a heterogeneity test showed that industrial capital and commercial capital has a stronger role in promoting the sustainable development of agriculture in non-major grain producing areas, areas with high marketization level and central and western regions; (3) the test of the transmission mechanism showed that industrial capital and commercial capital can promote the sustainable development of agriculture by optimizing agricultural production conditions, improving rural environment and promoting farmers' poverty reduction and common prosperity; (4) further research showed that industrial and commercial capital has a positive spillover effect on the sustainable development of agriculture in neighboring areas while promoting the sustainable development of agriculture in this region. Based on the above conclusions, this paper puts forward some countermeasures and suggestions, such as improving rural infrastructure construction, strengthening efforts to guide industrial and commercial capital to the countryside, and paying attention to the differentiation of industrial and commercial capital investment development.