Ecologists debate the relative importance of niche versus neutral processes in understanding biodiversity [1,2]. This debate is especially pertinent to microbial communities, which play crucial roles in biogeochemical cycling [3,4], food production , industrial processes [6,7], and human health and disease . Here we created a synthetic microbial community using heritable genetic barcodes and tracked community composition over time across a range of experimental conditions. We show that a transition exists between the neutral and niche regimes, and, consistent with theory, the crossover point depends on factors including immigration, fitness, and population size. We find that diversity declined most rapidly at intermediate population sizes, which can be explained by a tradeoff between replacement by migration and duration of growth. We then ran an experiment where the community underwent abrupt or gradual changes in size, the outcome of which highlights that selecting the correct model is essential to managing diversity. Taken together these results emphasize the importance of including niche effects to obtain realistic models across a wide range of parameters, even in simple systems.