Cyanobacteria can be found in almost every terrestrial and aquatic habitat – oceans, fresh water, damp soil, temporarily moistened rocks in deserts, bare rock and soil, and even Antarctic rocks. They can occur as planktonic cells or form phototrophic biofilms. They are found inside stones and shells (in endolithic ecosystems). A few are endosymbionts in lichens, plants, various protists, or sponges and provide energy for the host. Some live in the fur of sloths, providing a form of camouflage.
Aquatic cyanobacteria are known for their extensive and highly visible blooms that can form in both freshwater and marine environments. The blooms can have the appearance of blue-green paint or scum. These blooms can be toxic, and frequently lead to the closure of recreational waters when spotted. Marine bacteriophages are significant parasites of unicellular marine cyanobacteria.
Cyanobacterial growth is favoured in ponds and lakes where waters are calm and have little turbulent mixing. Their lifecycles are disrupted when the water naturally or artificially mixes from churning currents caused by the flowing water of streams or the churning water of fountains. For this reason blooms of cyanobacteria seldom occur in rivers unless the water is flowing slowly. Growth is also favoured at higher temperatures which enable Microcystis species to outcompete diatoms and green algae, and potentially allow development of toxins.
Based on environmental trends, models and observations suggest cyanobacteria will likely increase their dominance in aquatic environments. This can lead to serious consequences, particularly the contamination of sources of drinking water. Researchers including Linda Lawton at Robert Gordon University, have developed techniques to study these. Cyanobacteria can interfere with water treatment in various ways, primarily by plugging filters (often large beds of sand and similar media) and by producing cyanotoxins, which have the potential to cause serious illness if consumed. Consequences may also lie within fisheries and waste management practices. Anthropogenic eutrophication, rising temperatures, vertical stratification and increased atmospheric carbon dioxide are contributors to cyanobacteria increasing dominance of aquatic ecosystems.
Cyanobacteria have been found to play an important role in terrestrial habitats and organism communities. It has been widely reported that cyanobacteria soil crusts help to stabilize soil to prevent erosion and retain water. An example of a cyanobacterial species that does so is Microcoleus vaginatus. M. vaginatus stabilizes soil using a polysaccharide sheath that binds to sand particles and absorbs water. M. vaginatus also makes a significant contribution to the cohesion of biological soil crust.
Some of these organisms contribute significantly to global ecology and the oxygen cycle. The tiny marine cyanobacterium Prochlorococcus was discovered in 1986 and accounts for more than half of the photosynthesis of the open ocean. Circadian rhythms were once thought to only exist in eukaryotic cells but many cyanobacteria display a bacterial circadian rhythm.