Aqueous foams are used extensively in many fields and anionic surfactants are commonly used foaming agents. However, potential trouble may arise when they are utilized in hard water areas and/or at low temperatures. Anionic surfactants, like sodium dodecyl sulfate (SDS), may precipitate in the form of crystals when the concentration of divalent counterions such as Mg2+ exceeds a certain limit. In an attempt to prepare ultra-stable foams containing precipitated crystals, the behaviour of SDS in water was systematically investigated as a function of surfactant concentration at different concentrations of Mg(NO3)2 prior to a study of their foam properties. We quantitatively study the conversion of surfactant micelles to crystals and the re-dissolution of crystals into micelles. It was found that the presence of surfactant crystals reduced the initial foam volume and foam half-life but greatly improved the long-term stability of foams. Foam studies were also conducted for the supernatant and sediment isolated from crystal dispersions so that the importance of surfactant crystals to foam stability could be established. Despite the foamability of a sediment being low, an order of magnitude increase in foam half-life was related to the coverage of bubble surfaces by surfactant crystals. Both rapid cooling and ultrasonication were shown to influence the surfactant crystal shape and size with an impact on foam properties.