The existing medium and long-term runoff prediction methods, which are based on data-driven and knowledge-guided methods, are associated with inherent limitations, and chaotic phenomena in runoff prediction models often leads to oscillation in the prediction error, affecting the robustness of the prediction. A knowledge-guided denoising diffusion probabilistic model (DK-RDDPM) that introduces physical theory to guide constraint quantification and obtain effective runoff uncertainty prediction results is therefore proposed in this study. The main advantage of this model is that the physical randomness in the runoff prediction process can be captured and combined with the Saint-Venant process to guide model optimization and realize more accurate medium- and long-term runoff prediction. The main contributions of this study are the establishment of a dynamic runoff probabilistic prediction model with stochastic quantification characteristics that includes the prediction uncertainty over time, and modelling of the physical constraint boundary of runoff prediction from the perspective of partial differentiation. The effectiveness of the DK-RDDPM was verified by predicting runoff in the Qijiang and Tunxi Basins in China. The results show that: 1) Encoding the physical random uncertainty operator in runoff prediction into the network of the denoising diffusion probabilistic model (DDPM) effectively captures the physically complex implicit randomness of the process, thus reducing the error that results from randomness in runoff prediction. 2) The constraint matrix that is formed using the Saint-Venant equation and the prediction matrix are layered and projected, with the fluctuation range of the constraints in each step adjusted in the optimization direction within a certain random threshold range. 3) The DK-RDDPM shows superior performance to the benchmark models, even under the influence of different noise interference factors.