Climate change and human activities have altered the natural state of rivers to a certain extent, leading to runoff variation and impacting the stability of riverine ecosystems. The ecological flow has emerged to balance the water relationship between humanity and riverine ecosystems and to safeguard the health and biodiversity of rivers. Presently, the scientific quantification of riverine ecological flow has become a focal point in water resource research. Addressing the quantification of ecological flow under hydrological variation conditions, the cumulative deviation method (CDM) and Pettitt methods were firstly employed to detect breakpoints in the runoff sequences. Then, the natural monthly runoff post-variation was restored using the Soil and Water Assessment Tool (SWAT) model, i.e., natural runoff restoration, and three testing methods were employed to determine the optimal hydrological distribution functions for natural monthly runoff. Subsequently, an improved frequency calculation method was used to calculate the ecological flow. The Jinsha River Basin was selected as the study area, and four crucial sections in the mainstream of the Jinsha River were studied, including Zhimenda (ZMD), Shigu (SG), Xiaodeshi (XDS), and Pingshan (PS). The results indicated: (1) the runoff sequences (1960–2017) at the four crucial sections exhibit different breakpoint times, with breakpoint years being 2004, 1986, 2005, and 1996, respectively; (2) the SWAT model, in simulating runoff at the four crucial sections, exhibited NSE values all exceeding 0.85, and r values all surpassing 0.9, demonstrating its effective ability to restore natural runoff in the Jinsha River basin; (3) the optimal hydrological distribution functions for natural monthly runoff at the four sections varied, and most natural monthly runoff conforms to the Generalized Extreme Value (GEV) distribution; (4) the average annual ecological flows for the ZMD, SG, XDS, and PS sections were 296 m3/s, 992 m3/s, 1238 m3/s, and 2755 m3/s, and the ecological flows derived using the improved frequency calculation method under the optimal hydrological distribution functions were more rational. This study can provide a scientific basis for the optimal allocation of water resources and the protection of riverine ecosystems in the Jinsha River basin.