Minority ethnic and migrant groups face an elevated risk of compulsory admission for mental illness. There are overlapping cultural, socio-demographic, and structural explanations for this risk that require further investigation. By linking Swedish national register data, we established a cohort of persons first diagnosed with a psychotic disorder between 2001 and 2016. We used multilevel mixed-effects logistic modelling to investigate variation in compulsory admission at first diagnosis of psychosis across migrant and Swedish-born groups with individual and neighbourhood-level covariates. Our cohort included 12 000 individuals, with 1298 (10.8%) admitted compulsorily. In an unadjusted model, being a migrant [odds ratio (OR) 1.48; 95% confidence interval (CI) 1.26-1.73] or child of a migrant (OR 1.27; 95% CI 1.10-1.47) increased risk of compulsory admission. However after multivariable modelling, region-of-origin provided a better fit to the data than migrant status; excess risk of compulsory admission was elevated for individuals from sub-Saharan African (OR 1.94; 95% CI 1.51-2.49), Middle Eastern and North African (OR 1.46; 95% CI 1.17-1.81), non-Nordic European (OR 1.27; 95% CI 1.01-1.61), and mixed Swedish-Nordic backgrounds (OR 1.33; 95% CI 1.03-1.72). Risk of compulsory admission was greater in more densely populated neighbourhoods [OR per standard deviation (s.d.) increase in the exposure: 1.12, 95% CI 1.06-1.18], an effect that appeared to be driven by own-region migrant density (OR per s.d. increase in exposure: 1.12; 95% CI 1.02-1.24). Inequalities in the risk of compulsory admission by migrant status, region-of-origin, urban living and own-region migrant density highlight discernible factors which raise barriers to equitable care and provide potential targets for intervention.