We present the first reconstruction of the star formation history (SFH) of the Large and Small Magellanic Clouds (LMC and SMC) using Long Period Variable stars. These cool evolved stars reach their peak luminosity in the near-infrared; thus, their K-band magnitudes can be used to derive their birth mass and age, and hence the SFH can be obtained. In the LMC, we found a 10-Gyr old single star formation epoch at a rate of $sim1.5$ M$_odot$ yr$^{-1}$, followed by a relatively continuous SFR of $sim0.2$ M$_odot$ yr$^{-1}$, globally. In the core of the LMC (LMC bar), a secondary, distinct episode is seen, starting 3 Gyr ago and lasting until $sim0.5$ Gyr ago. In the SMC, two formation epochs are seen, one $sim6$ Gyr ago at a rate of $sim0.28$ M$_odot$ yr$^{-1}$ and another only $sim0.7$ Gyr ago at a rate of $sim0.3$ M$_odot$ yr$^{-1}$. The latter is also discernible in the LMC and may thus be linked to the interaction between the Magellanic Clouds and/or Milky Way, while the formation of the LMC bar may have been an unrelated event. Star formation activity is concentrated in the central parts of the Magellanic Clouds now, and possibly has always been if stellar migration due to dynamical relaxation has been effective. The different initial formation epochs suggest that the LMC and SMC did not form as a pair, but at least the SMC formed in isolation.