We use new multiwavelength radio observations, made with the VLA and Effelsberg telescopes, to study the magnetic field of the nearby galaxy M51 on scales from 200 pc to several kpc. Interferometric and single-dish data are combined to obtain new maps at λλ3, 6 cm in total and polarized emission, and earlier λ20 cm data are rereduced. We compare the spatial distribution of the radio emission with observations of the neutral gas, derive radio spectral index and Faraday depolarization maps, and model the large-scale variation in Faraday rotation in order to deduce the structure of the regular magnetic field. We find that the λ20 cm emission from the disc is severely depolarized and that a dominating fraction of the observed polarized emission at λ6 cm must be due to anisotropic small-scale magnetic fields. Taking this into account, we derive two components for the regular magnetic field in this galaxy; the disc is dominated by a combination of azimuthal modes, m= 0 + 2, but in the halo only an m= 1 mode is required to fit the observations. We discuss how the observed arm–interarm contrast in radio intensities can be reconciled with evidence for strong gas compression in the spiral shocks. In the inner spiral arms, the strong arm–interarm contrasts in total and polarized radio emission are roughly consistent with expectations from shock compression of the regular and turbulent components of the magnetic field. However, the average arm–interam contrast, representative of the radii r > 2 kpc where the spiral arms are broader, is not compatible with straightforward compression: lower arm–interarm contrasts than expected may be due to resolution effects and decompression of the magnetic field as it leaves the arms. We suggest a simple method to estimate the turbulent scale in the magneto-ionic medium from the dependence of the standard deviation of the observed Faraday rotation measure on resolution. We thus obtain an estimate of 50 pc for the size of the turbulent eddies.