Summary. The conventional Wilcoxon or Mann–Whitney test can be invalid for comparing treatment effects in the presence of missing values or in observational studies. This is because the missingness of the outcomes or the participation in the treatments may depend on certain pretreatment variables. We propose an approach to adjust the Mann–Whitney test by correcting the potential bias via consistently estimating the conditional distributions of the outcomes given the pretreatment variables. We also propose semiparametric extensions of the adjusted Mann–Whitney test which lead to dimension reduction for high dimensional covariates. A novel bootstrap procedure is devised to approximate the null distribution of the test statistics for practical implementations. Results from simulation studies and an economics observational study data analysis are presented to demonstrate the performance of the approach proposed.