We present the theory for wave equation inversion of dispersion curves obtained from traces containing guided P waves. The misfit function is the sum of the squared differences between the wavenumbers along the predicted and observed dispersion curves, and the inverted result is a high-resolution estimate of the near-surface P-velocity model. This procedure, denoted as the wave equation dispersion inversion of guided P waves (WDG), is valid for near-surface waveguides with irregular layers. It is less prone to the cycle skipping problems of full waveform inversion (FWI) and can sometimes provide velocity models with higher resolution than wave-equation traveltime tomography (WT). The synthetic and field data examples demonstrate that WDG for guided P waves can accurately reconstruct the P-wave velocity distribution in laterally heterogeneous media.