We present and develop a general dispersive framework allowing to construct representations of the amplitudes for the processes Pπ→ππ, P=K,η, valid at the two-loop level in the low-energy expansion. The construction proceeds through a two-step iteration, starting from the tree-level amplitudes and their S and P partial-wave projections. The one-loop amplitudes are obtained for all possible configurations of pion masses. The second iteration is presented in detail in the cases where either all masses of charged and neutral pions are equal, or for the decay into three neutral pions. Issues related to analyticity properties of the amplitudes and of their lowest partial-wave projections are given particular attention. This study is introduced by a brief survey of the situation, for both experimental and theoretical aspects, of the decay modes into three pions of charged and neutral kaons and of the eta meson.