The future energy systems dominated by variable renewable energy sources require system flexibility for balancing fluctuating supply and demand. This study is motivated by the need to investigate how sector coupling between the power and district heating sectors can enhance flexibility. It is hypothesised that a partially disaggregated sector-coupling approach can efficiently capture interactions between energy generation, conversion, and storage technologies. A mathematical optimisation framework is developed to analyse cost-optimal and environmentally benign energy system transitions in Sweden up to 2050. The model accounts for the ten largest Swedish district heating systems integrated within the national power system. Results reveal that wind turbines, with a 56% share, supported by electricity storage dominate electricity generation in 2050. Electricity storage enables demand to be met with 7% lower installed power generation capacity. The resulting generation mix drives a shift in district heating supply, with the heat generation share of combined heat and power plants declining to 24% and that of heat pumps increasing to 61% by 2050. Seasonal thermal storage systems play an important role in this shift, supplying 11% of district heating demand. However, transitions towards low-temperature district heating reduce the seasonal storage share while further favouring heat pumps (up to 80% of heat generation). Increased availability of stable waste heat for direct district heating supply also diminishes the role of seasonal heat storage. Overall, the results highlight that district heating provides a flexibility service for the energy system, but multiple flexibility solutions are needed to fully exploit electricity oversupply. © 2026 The Author(s).