The photoinjector test facility at DESY, Zeuthen site (PITZ), was built to develop and optimize photoelectron sources for superconducting linacs for high-brilliance, short-wavelength free-electron laser (FEL) applications like the free-electron laser in Hamburg (FLASH) and the European x-ray free-electron laser (XFEL). In this paper, the detailed characterization of two laser-driven rf guns with different operating conditions is described. One experimental optimization of the beam parameters was performed at an accelerating gradient of about 43 MV=m at the photocathode and the other at about 60 MV=m. In both cases, electron beams with very high phase-space density have been demonstrated at a bunch charge of 1 nC and are compared with corresponding simulations. The rf gun optimized for the lower gradient has surpassed all the FLASH requirements on beam quality and rf parameters (gradient, rf pulse length, repetition rate) and serves as a spare gun for this facility. The rf gun studied with increased accelerating gradient at the cathode produced beams with even higher brightness, yielding the first demonstration of the beam quality required for driving the European XFEL: The geometric mean of the normalized projected rms emittance in the two transverse directions was measured to be 1:26 ` 0:13 mm mrad for a 1-nC electron bunch. When a 10% charge cut is applied excluding electrons from those phase-space regions where the measured phase-space density is below a certain level and which are not expected to contribute to the lasing process, the normalized projected rms emittance is about 0.9 mm mrad