We study the earning structure and the equilibrium assignment of workers to firms in a model in which workers have social preferences, and skills are perfectly substitutable in production. Firms offer long-term contracts, and we allow for frictions in the labour market in the form of mobility costs. The model delivers specific predictions about the nature of worker flows, about the characteristics of workplace skill segregation, and about wage dispersion both within and across firms. We show that long-term contracts in the presence of social preferences associate within-firm wage dispersion with novel "internal labour market" features such as gradual promotions, productivity-unrelated wage increases, and downward wage flexibility. These three dynamic features lead to productivity-unrelated wage volatility within firms. © 2008 The Review of Economic Studies Limited.