Diffractive electroproduction of ρ and φ mesons is measured at HERA with the H1 detector in the elastic and proton dissociative channels. The data correspond to an integrated luminosity of 51 pb −1 . About 10500 ρ and 2000 φ events are analysed in the kinematic range of squared photon virtuality 2.5 ≤ Q 2 ≤ 60 GeV 2 , photon-proton centre of mass energy 35 ≤ W ≤ 180 GeV and squared four-momentum transfer to the proton |t| ≤ 3 GeV 2 . The total, longitudinal and transverse cross sections are measured as a function of Q 2 , W and |t|. The measurements show a transition to a dominantly "hard" behaviour, typical of high gluon densities and small qq dipoles, for Q 2 larger than 10 to 20 GeV 2 . They support flavour independence of the diffractive exchange, expressed in terms of the scaling variable (Q 2 +M 2 V )/4, and proton vertex factorisation. The spin density matrix elements are measured as a function of kinematic variables. The ratio of the longitudinal to transverse cross sections, the ratio of the helicity amplitudes and their relative phases are extracted. Several of these measurements have not been performed before and bring new information on the dynamics of diffraction in a QCD framework. The measurements are discussed in the context of models using generalised parton distributions or universal dipole cross sections.