This paper develops a general framework for conducting inference on the rank of an unknown matrix \Pi_0. A defining feature of our setup is the null hypothesis of the form H_0: rank(\Pi_0)\leq r. The problem is of first order importance because the previous literature focuses on H_0': rank(\Pi_0)= r by implicitly assuming away rank(\Pi_0), which may lead to invalid rank tests due to over-rejections. In particular, we show that limiting distributions of test statistics under H_0' may not stochastically dominate those under rank(\Pi_0) < r. A multiple test on the nulls rank(\Pi_0)=0,...,r, though valid, may be substantially conservative. We employ a testing statistic whose limiting distributions under H_0 are highly nonstandard due to the inherent irregular natures of the problem, and then construct bootstrap critical values that deliver size control and improved power. Since our procedure relies on a tuning parameter, a two-step procedure is designed to mitigate concerns on this nuisance. We additionally argue that our setup is also important for estimation. We illustrate the empirical relevance of our results through testing identification in linear IV models that allows for clustered data and inference on sorting dimensions in a two-sided matching model with transferrable utility.