This paper presents a test for exogeneity of explanatory variables in a nonparametric instrumental variables (IV) model whose structural function is identified through a conditional quantile restriction. Quantile regression models are increasingly important in applied econometrics. As with mean-regression models, an erroneous assumption that the explanatory variables in a quantile regression model are exogenous can lead to highly misleading results. In addition, a test of exogeneity based on an incorrectly specified parametric model can produce misleading results. This paper presents a test of exogeneity that does not assume the structural function belongs to a known finite-dimensional parametric family and does not require nonparametric estimation of this function. The latter property is important because, owing to the ill-posed inverse problem, a test based on a nonparametric estimator of the structural function has low power. The test presented here is consistent whenever the structural function differs from the conditional quantile function on a set of non-zero probability. The test has non-trivial power uniformly over a large class of structural functions that differ from the conditional quantile function by O(n−1/2) . The results of Monte Carlo experiments illustrate the usefulness of the test.