Comparison between formulae for the counting functions of the heights t n of the Riemann zeros and of semiclassical quantum eigenvalues En suggests that the t n are eigenvalues of an (unknown) hermitean operator H, obtained by quantizing a classical dynamical system with hamiltonian H cl . Many features of H cl are provided by the analogy; for example, the "Riemann dynamics" should be chaotic and have periodic orbits whose periods are multiples of logarithms of prime numbers. Statistics of the t n have a similar structure to those of the semiclassical En ; in particular, they display random-matrix universality at short range, and nonuniversal behaviour over longer ranges. Very refined features of the statistics of the t n can be computed accurately from formulae with quantum analogues. The Riemann-Siegel formula for the zeta function is described in detail. Its interpretation as a relation between long and short periodic orbits gives further insights into the quantum spectral fluctuations. We speculate that the Riemann dynamics is related to the trajectories generated by the classical hamiltonian H cl = XP. Key words. spectral asymptotics, number theory AMS subject classifications. 11M26, 11M06, 35P20, 35Q40, 41A60, 81Q10, 81Q50 PII. S0036144598347497 1.