A body of literature suggests that ethnic heterogeneity limits economic growth. This paper provides microeconometric evidence on the direct effect of ethnic divisions on productivity. In team production at a plant in Kenya, an upstream worker supplies and distributes flowers to two downstream workers who assemble them into bunches. The plant uses an essentially random rotation process to assign workers to positions, leading to three types of teams: (a) ethnically homogeneous teams, and teams in which (b) one or (c) both downstream workers belong to a tribe in rivalry with the upstream worker's tribe. I find strong evidence that upstream workers undersupply non-coethnic downstream workers (vertical discrimination) and shift flowers from non-coethnic to coethnic downstream workers (horizontal discrimination), at the cost of lower own pay and total output. A period of ethnic conflict following Kenya's 2007 election led to a sharp increase in discrimination. In response, the plant began paying the two downstream workers for their combined output (team pay). This led to a modest output reduction in (a) and (c) teams - as predicted by standard incentive models - but an increase in output in (b) teams, and overall. Workers' behavior before conflict, during conflict, and under team pay is predicted by a model of taste-based discrimination. My findings suggest that inter-ethnic rivalries lower allocative efficiency in the private sector, that the economic costs of ethnic diversity vary with the political environment, and that in high-cost environments firms are forced to adopt second best policies to limit discrimination distortions.