A test is proposed for the independence of two random variables with continuous distribution function (d.f.). The test is consistent with respect to the class $\Omega''$ of d.f.'s with continuous joint and marginal probability densities (p.d.). The test statistic $D$ depends only on the rank order of the observations. The mean and variance of $D$ are given and $\sqrt n(D - ED)$ is shown to have a normal limiting distribution for any parent distribution. In the case of independence this limiting distribution is degenerate, and $nD$ has a non-normal limiting distribution whose characteristic function and cumulants are given. The exact distribution of $D$ in the case of independence for samples of size $n = 5, 6, 7$ is tabulated. In the Appendix it is shown that there do not exist tests of independence based on ranks which are unbiased on any significance level with respect to the class $\Omega''$. It is also shown that if the parent distribution belongs to $\Omega''$ and for some $n \geq 5$ the probabilities of the $n!$ rank permutations are equal, the random variables are independent.