A random-matrix theory is developed for the adiabatic response to an external perturbation of the energy spectrum of a mesoscopic system. The basic assumption is that spectral correlations are governed by level repulsion. Following Dyson, the dependence of the energy levels on the perturbation parameter is modeled by a Brownian-motion process in a fictitious viscous fluid. A Fokker-Planck equation for the evolution of the distribution function is solved to yield the correlation of level densities at different energies and different parameter values. An approximate solution is obtained by asymptotic expansion and an exact solution by mapping onto a free-fermion model. A generalization to multiple parameters is also considered, corresponding to Brownian motion in a fictitious world with multiple temporal dimensions. Complete agreement is obtained with microscopic theory.