Sandcastle worms Phragmatopoma californica build mound-like reefs by sticking together large numbers of sand grains with cement secreted from the building organ. The cement consists of protein plus substantial amounts of calcium and magnesium, which are not invested in any mineral form. This study examined the effect of calcium and magnesium depletion on the structural and mechanical properties of the cement. Divalent ion removal by chelating with EDTA led to a partial collapse of cement architecture and cement dislodgement from silica surfaces. Mechanical properties examined were sand grain pull-out force, tube resistance to compression and cement adhesive force. EDTA treatment reduced sand grain pull-out forces by 60% and tube compressive strength by 50% relative to controls. EDTA lowered both the maximal adhesive force and energy dissipation of cement by up to an order of magnitude. The adhesiveness of calcium- and magnesium-depleted cement could not be restored by re-exposure to the ions. The results suggest that divalent ions play a complex and multifunctional role in maintaining the structure and stickiness of Phragmatopoma cement.