Entrywise functions preserving the cone of positive semidefinite matrices have been studied by many authors, most notably by Schoenberg [Duke Math. J. 9, 1942] and Rudin [Duke Math. J. 26, 1959]. Following their work, it is well-known that entrywise functions preserving Loewner positivity in all dimensions are precisely the absolutely monotonic functions. However, there are strong theoretical and practical motivations to study functions preserving positivity in a fixed dimension $n$. Such characterizations for a fixed value of $n$ are difficult to obtain, and in fact are only known in the $2 times 2$ case. In this paper, using a novel and intuitive approach, we study entrywise functions preserving positivity on distinguished submanifolds inside the cone obtained by imposing rank constraints. These rank constraints are prevalent in applications, and provide a natural way to relax the elusive original problem of preserving positivity in a fixed dimension. In our main result, we characterize entrywise functions mapping $n times n$ positive semidefinite matrices of rank at most $l$ into positive semidefinite matrices of rank at most $k$ for $1 leq l leq n$ and $1 leq k < n$. We also demonstrate how an important necessary condition for preserving positivity by Horn and Loewner [Trans. Amer. Math. Soc. 136, 1969] can be significantly generalized by adding rank constraints. Finally, our techniques allow us to obtain an elementary proof of the classical characterization of functions preserving positivity in all dimensions obtained by Schoenberg and Rudin.