In this third paper of a series dedicated to a dispersive treatment of the hadronic light-by-light (HLbL) tensor, we derive a partial-wave formulation for two-pion intermediate states in the HLbL contribution to the anomalous magnetic moment of the muon (g − 2) µ , including a detailed discussion of the unitarity relation for arbitrary partial waves. We show that obtaining a final expression free from unphysical helicity partial waves is a subtle issue, which we thoroughly clarify. As a by-product, we obtain a set of sum rules that could be used to constrain future calculations of γ * γ * → ππ. We validate the formalism extensively using the pion-box contribution, defined by two-pion intermediate states with a pion-pole left-hand cut, and demonstrate how the full known result is reproduced when resumming the partial waves. Using dispersive fits to high-statistics data for the pion vector form factor, we provide an evaluation of the full pion box, a π-box µ = −15.9(2)×10 −11 . As an application of the partial-wave formalism, we present a first calculation of ππ-rescattering effects in HLbL scattering, with γ * γ * → ππ helicity partial waves constructed dispersively using ππ phase shifts derived from the inverse-amplitude method. In this way, the isospin-0 part of our calculation can be interpreted as the contribution of the f 0 (500) to HLbL scattering in (g − 2) µ . We argue that the contribution due to charged-pion rescattering implements corrections related to the corresponding pion polarizability and show that these are moderate. Our final result for the sum of pion-box contribution and its S-wave rescattering corrections reads a π-box µ + a ππ,π-pole LHC µ,J=0 = −24(1) × 10 −11 .