This paper analyses how labour institutions and ethnic identity shape favouritism and discrimination among workers. We conduct an experiment with union and non-union South African mineworkers from various ethnicities. We examine in-group and out-group behaviour, emphasizing the relative ranking of these groups and their interaction. We find that unions create both in-group and out-group favouritism towards co-ethnic members and members of ethnic majorities. This favouritism is however undermined by unionised subcontract workers who experience precarious conditions. Furthermore, union members discriminate against non-unionised ethnic minorities. Finally, non-union members (primarily subcontract workers) discriminate against union members, particularly after negative shocks.