We have obtained the time and space-resolved star formation history (SFH) of M51a (NGC 5194) by fitting GALEX, SDSS, and near infrared pixel-by-pixel photometry to a comprehensive library of stellar population synthesis models drawn from the Synthetic Spectral Atlas of Galaxies (SSAG). We fit for each space-resolved element (pixel) an independent model where the SFH is averaged in 137 age bins, each one 100 Myr wide. We used the Bayesian Successive Priors (BSP) algorithm to mitigate the bias in the present-day spatial mass distribution. We test BSP with different prior probability distribution functions (PDFs); this exercise suggests that the best prior PDF is the one concordant with the spatial distribution of the stellar mass as inferred from the near infrared images. We also demonstrate that varying the implicit prior PDF of the SFH in SSAG does not affects the results. By summing the contributions to the global star formation rate of each pixel, at each age bin, we have assembled the resolved star formation history of the whole galaxy. According to these results, the star formation rate of M51a was exponentially increasing for the first 10 Gyr after the Big Bang, and then turned into an exponentially decreasing function until the present day. Superimposed, we find a main burst of star formation at t 11.9 Gyr after the Big Bang.