We introduce a notion of $n$-Lie Rinehart algebras as a generalization of Lie Rinehart algebras to $n$-ary case. This notion is also an algebraic analogue of $n$-Lie algebroids. We develop representation theory and describe a cohomology complex of $n$-Lie Rinehart algebras. Furthermore, we investigate extension theory of $n$-Lie Rinehart algebras by means of $2$-cocycles. Finally, we introduce crossed modules of $n$-Lie Rinehart algebras to gain a better understanding of their third dimensional cohomology groups.