Geographical isolation facilitates the emergence of distinct phenotypes within a single species, but reproductive barriers or selection is needed to maintain the polymorphism after secondary contact. Here, we explore the processes that maintain intraspecific variation of C4 photosynthesis, a complex trait that results from the combined action of multiple genes. The grass Alloteropsis semialata includes C4 and non-C4 populations, which have co-existed for more than one million years in the miombo woodlands of Africa. Using population genomics, we show that there is genome-wide divergence for the photosynthetic types, but the current distribution is not a result of a simple habitat displacement scenario as the genetic clusters overlap in ecology and geography, being occasionally mixed within a given habitat. We find evidence of introgression between photosynthetic types, but hybrids are rare and no clear hybrid zone is formed. Selection against hybrids likely limits gene flow and differentiation is accentuated in multiple parts of the genome pointing to selection on numerous genes. Coupled with strong isolation by distance within each genetic group, this selection created a geographical mosaic of photosynthetic types, which was further reinforced by recurrent polyploidization. Together, these factors enabled the persistence of divergent physiological traits of ecological importance within a single species despite gene flow and habitat overlap.