Insect societies vary greatly in social organization, yet the relative roles of ecological and genetic factors in driving this variation remain poorly understood. Identifying how social structure varies along environmental gradients can provide insights into the ecological conditions favouring alternative social organizations. Here, we investigate how queen number variation is distributed along elevation gradients within a socially polymorphic ant, the Alpine silver ant Formica selysi. We sampled low- and high-elevation populations in multiple Alpine valleys. We show that populations belonging to different drainage basins are genetically differentiated. In contrast, there is little genetic divergence between low- and high-elevation populations within the same drainage basin. Thus, elevation gradients in each of the drainage basins represent independent contrasts. Whatever the elevation, all well-sampled populations are socially polymorphic, containing both monogynous (= one queen) and polygynous (= multiple queen) colonies. However, the proportion of monogynous colonies per population increases at higher elevation, while the effective number of queens in polygynous colonies decreases, and this pattern is replicated in each drainage basin. The increased prevalence of colonies with a single queen at high elevation is correlated with summer and winter average temperature, but not with precipitation. The colder, unpredictable and patchy environment encountered at higher elevations may favour larger queens with the ability to disperse and establish incipient monogynous colonies independently, while the stable and continuous habitat in the lowlands may favour large, fast-growing polygynous colonies. By highlighting differences in the environmental conditions favouring monogynous or polygynous colonies, this study sheds light on the ecological factors influencing the distribution and maintenance of social polymorphism.