The evolutionary dynamics of specialization, in the context of the division of labour, are investigated. Individuals associate in groups in which benefits are shared and costs borne individually; each individual is either a generalist who can perform all the necessary tasks, a specialist who performs a sub-set of the necessary tasks, or a parasite who contributes nothing to the group. The implications of the model are explored analytically and through both numerical and Monte Carlo methods. These methods demonstrate the evolution of populations towards stable arrangements of specialists and generalists. The fittest populations are those that divide tasks fairly and associate in large, highly specialized groups. Generalists have a distinct advantage in small groups, but the presence of generalists, ironically, lowers group fitness. Parasites are able to invade both specialized and non-specialized populations. A basic model for the continuous division of labour is also presented, demonstrating a tendency for populations to evolve increasingly unfair divisions of labour. This last result implies that an evolutionary ratchet favours disparity between the workload of specialist populations.