The cross section of the diffractive process e^+p -> e^+Xp is measured at a centre-of-mass energy of 318 GeV, where the system X contains at least two jets and the leading final state proton p is detected in the H1 Very Forward Proton Spectrometer. The measurement is performed in photoproduction with photon virtualities Q^2 <2 GeV^2 and in deep-inelastic scattering with 4 GeV^2<Q^2<80 GeV^2. The results are compared to next-to-leading order QCD calculations based on diffractive parton distribution functions as extracted from measurements of inclusive cross sections in diffractive deep-inelastic scattering.