Magnetostriction, the strain induced by a change in magnetization, is a universal effect in magnetic materials. Owing to the difficulty in unraveling its microscopic origin, it has been largely treated phenomenologically. Here, we show how the source of magnetostriction—the underlying magnetoelastic stress—can be separated in the time domain, opening the door for an atomistic understanding. X-ray and electron diffraction are used to separate the sub-picosecond spin and lattice responses of FePt nanoparticles. Following excitation with a 50-fs laser pulse, time-resolved X-ray diffraction demonstrates that magnetic order is lost within the nanoparticles with a time constant of 146 fs. Ultrafast electron diffraction reveals that this demagnetization is followed by an anisotropic, three-dimensional lattice motion. Analysis of the size, speed, and symmetry of the lattice motion, together with ab initio calculations accounting for the stresses due to electrons and phonons, allow us to reveal the magnetoelastic stress generated by demagnetization.