Femtosecond x-ray diffraction provides direct insight into the ultrafast reversible lattice dynamics of materials with a perovskite structure. Superlattice (SL) structures consisting of a sequence of nanometer-thick layer pairs allow for optically inducing a tailored stress profile that drives the lattice motions and for limiting the influence of strain propagation on the observed dynamics. We demonstrate this concept in a series of diffraction experiments with femtosecond time resolution, giving detailed information on the ultrafast lattice dynamics of ferroelectric and ferromagnetic superlattices. Anharmonically coupled lattice motions in a SrRuO 3 /PbZr 0.2 Ti 0.8 O 3 (SRO/PZT) SL lead to a switch-off of the electric polarizations on a time scale of the order of 1 ps. Ultrafast magnetostriction of photoexcited SRO layers is demonstrated in a SRO/SrTiO 3 (STO) SL.