The crystal structure of the environmental-friendly flame retardant melaminium polyphosphate [MPoly] (2,4,6-triamino-1,3,5-triazinium·PO3)n was determined by a direct-space global optimization technique from X-ray powder-diffraction data. Solid-state NMR was used to corroborate the proposed hydrogen-bonding model and to determine the average degree of polymerization (n>100). An analysis of the crystal structure of MPoly reveals aspects of molecular geometry and packing that are characteristic for melamine-containing compounds and polyphosphate salts. A comparison of MPoly with the crystal structures of its precursors melaminium orthophosphate (MP) and melaminium dihydrogenpyrophosphate (MPy) provides insight in the mechanism of the endothermic dehydration processes that take place in the reaction path MP→MPy→MPoly. Solid-state NMR characterization of various samples of the same batch showed inhomogeneities in the Mpoly composition. Various quantities of orthophosphates were found, which cannot be assigned to be MP.