Polysaccharides have been recognized as a significant type of foulant due to their gelling property which is deeply affected by the existence of divalent cations. However, the effect of magnesium ion on polysaccharides fouling remains largely unknown and results reported by the limited studies are even controversial. In this study, alginate samples were employed to systematically study the effect of Mg2+ on polysaccharides fouling. Four levels of alginates were studied and results led to the same conclusion that the presence of Mg2+ aggravated fouling problems during membrane filtration. Cross-validation of filtration resistances, modelling of filtration data and autopsy of fouled membrane revealed that gel layer formation was the dominant fouling mechanism at the presence of Mg2+. Further analysis showed that the gel layer development strongly depended on the crosslinking of alginate. Moreover, crosslinking of alginate was enhanced by the Mg2+-alginate interaction including Mg2+⋯O(COO−) bonds, Mg2+⋯O(OH) bonds and sharing water molecules from the first coordination shell of Mg2+ with the carboxylate groups of alginate. Increased crosslinking of alginates resulted with the formation of networks with larger effective dimension and more complex three dimension structure, i.e. the transparent exopolymer particles (TEP). TEP promoted the gel layer formation on membrane. Emphasis is given to the link between the Mg2+-polysaccharide interaction and the fouling propensity of polysaccharides. Consequently, understanding the interaction between cations and organic foulants is important, which would provide an insightful guidance for fouling control.