Heterocysts are specialized, thick-walled cells in filamentous cyanobacteria (e.g., Anabaena) that provide an anaerobic microenvironment for nitrogenase enzyme activity. They lack photosystem II to avoid oxygen production, which inactivates nitrogenase, and fix atmospheric N$_2$ into ammonia.