The dazzling diversity of the phytoplankton has puzzled biologists for decades. The puzzle has been enlarged rather than solved by the progressive discovery of new phototrophic microorganisms in the oceans, including picocyanobacteria, pico-eukaryotes, and bacteriochlorophyll-based and rhodopsin-based phototrophic bacteria. Physiological and genomic studies suggest that natural selection promotes niche differentiation among these phototrophic microorganisms, particularly with respect to their photosynthetic characteristics. We have analysed competition for light between two closely related picocyanobacteria of the Synechococcus group that we isolated from the Baltic Sea. One of these two has a red colour because it contains the pigment phycoerythrin, whereas the other is blue-green because it contains high contents of the pigment phycocyanin. Here we report theory and competition experiments that reveal stable coexistence of the two picocyanobacteria, owing to partitioning of the light spectrum. Further competition experiments with a third marine cyanobacterium, capable of adapting its pigment composition, show that this species persists by investing in the pigment that absorbs the colour not used by its competitors. These results demonstrate the adaptive significance of divergence in pigment composition of phototrophic microorganisms, which allows an efficient utilization of light energy and favours species coexistence.