We consider the elementary divisors and determinant of a uniformly distributed $n \times n$ random matrix $M_n$ with entries in the ring of integers of an arbitrary local field. We show that the sequence of elementary divisors is in a simple bijective correspondence with a Markov chain on the nonnegative integers. The transition dynamics of this chain do not depend on the size of the matrix. As $n \rightarrow \infty$, all but finitely many of the elementary divisors are $1$, and the remainder arise from a Markov chain with these same transition dynamics. We also obtain the distribution of the determinant of $M_n$ and find the limit of this distribution as $n \rightarrow \infty$. Our formulae have connections with classical identities for $q$-series, and the $q$-binomial theorem in particular.