$Context$. The assembly history experienced by the Milky Way is currently being unveiled thanks to the data provided by the $Gaia$ mission. It is likely that the globular cluster system of our Galaxy has followed a similarly intricate formation path. $Aims$. To constrain this formation path, we explore the link between the globular clusters and the known merging events that the Milky Way has experienced. $Methods$. To this end, we combined the kinematic information provided by $Gaia$ for almost all Galactic clusters, with the largest sample of cluster ages available after carefully correcting for systematic errors. To identify clusters with a common origin we analysed their dynamical properties, particularly in the space of integrals of motion. $Results$. We find that about 40% of the clusters likely formed in situ. A similarly large fraction, 35%, appear to be possibly associated to known merger events, in particular to $Gaia$-Enceladus (19%), the Sagittarius dwarf galaxy (5%), the progenitor of the Helmi streams (6%), and to the Sequoia galaxy (5%), although some uncertainty remains due to the degree of overlap in their dynamical characteristics. Of the remaining clusters, 16% are tentatively associated to a group with high binding energy, while the rest are all on loosely bound orbits and likely have a more heterogeneous origin. The resulting age-metallicity relations are remarkably tight and differ in their detailed properties depending on the progenitor, providing further confidence on the associations made. $Conclusions$. We provide a table listing the likely associations. Improved kinematic data by future Gaia data releases and especially a larger, systematic error-free sample of cluster ages would help to further solidify our conclusions.