We have examined the biosynthesis and accumulation of cyanobacterial sunscreening pigment scytonemin within intertidal microbial mat communities using a combination of chemical, molecular, and phylogenetic approaches. Both laminated (layered) and nonlaminated mats contained scytonemin, with morphologically distinct mats having different cyanobacterial community compositions. Within laminated microbial mats, regions with and without scytonemin had different dominant oxygenic phototrophs, with scytonemin-producing areas consisting primarily of Lyngbya aestuarii and scytonemin-deficient areas dominated by a eukaryotic alga. The nonlaminated mat was populated by a diverse group of cyanobacteria and did not contain algae. The amplification and phylogenetic assignment of scytonemin biosynthetic gene scyC from laminated mat samples confirmed that the dominant cyanobacterium in these areas, L. aestuarii, is likely responsible for sunscreen production. This study is the first to utilize an understanding of the molecular basis of scytonemin assembly to explore its synthesis and function within natural microbial communities.