Individuals form groups, which subsequently develop larger domains via competition and coalescence. How much have these social processes in common with established mechanisms of phase transitions in physics? Are nucleation in metastable systems or spinodal decomposition of thermodynamic phases or percolation in porous media suitable paradigms for modeling the emergence of large social groups? We answer this challenging question by providing an agent-based model that combines group formation and opinion dynamics in a novel manner. Opinion formation determines the formation of groups which can form larger clusters of various numbers, density and stability. These clusters can merge, split or rearrange, to develop either compact phases, networks of high modularity, or quasistable cluster distributions. Dependent on the choice of parameters for opinion dynamics and social influence, our model can reproduce social phenomena such as consensus, community formation, weak or strong polarization, sparse social structures or stable minorities.