This paper reports on an experimental investigation and numerical simulation of the spatio-temporal dynamics of the pulse formation in flashlamp-pumped Q-switched Nd:YAG lasers. The temporal evolution of the spatial intensity distribution is measured with a fast two-dimensional CCD camera. The measurements are performed for two lasers with different cavity configurations. A laser with an optically stable resonator and an internal mode aperture generated pulses with a spatial intensity distribution which is Gaussian at all times during the 10-ns-long pulse. During the pulse evolution the value of the beam-quality factor M2 remains below 1.3. In a laser with a positive-branch unstable resonator the laser pulse also starts with a Gaussian intensity distribution, but becomes rapidly non-Gaussian. The corresponding M2 values increase from about 1 at the beginning of the formation of the pulse to more than 12 in the tail of the pulse. The measurements are compared with the results of a numerical simulation which takes the laser amplification, the properties of the laser cavity, and the diffraction of the beam in the laser cavity into account. The spatio-temporal dynamics of the pulse formation predicted by the numerical model are in good agreement with the experimental results.