In this paper we analyze the problem of optimal waveform design for synthetic-aperture radar (SAR) imaging through a dispersive medium. We use a scalar model for wave propagation, together with the single-scattering approximation, and we assume that measurements are polluted with thermal noise whose statistics are known. For image formation, we use a filtered backprojection algorithm in which the filter is determined by knowledge of the power-spectral densities of the scene and noise. In this framework, we derive a waveform which is optimal in the sense of minimizing the mean-square-error of the reconstructed image. We show the results of simulations for the example of imaging point scatterers embedded in a certain dispersive background. We show that for low signal-to-noise ratios, the optimal waveform resembles what is known as a precursor: a wave that is generated from propagating ultrawideband waveforms through the medium.