Emission, absorption, and excitation spectroscopy has been used for a detailed analysis of the optical transitions of Hg2 trapped in cryogenic matrices. Upon excitation of electronic states correlating to the 3P1 or the 1P1 asymptote, fast nonradiative relaxation leads to emission from the lowest excited A0g+ state in all matrices, which decays monoexponentially in 1 ms in Ne, 280 μs in Ar, and 12 μs in Xe. In addition, electronically unrelaxed emission of Hg2 is reported in neon and in xenon matrices and attributed to the B1g state in neon and to the B1g state and the C0u− or A0g− states in xenon. The results are rationalized by assuming: (a) that population of the excited states occurs mainly close to the asymptotic limit, where branching is determined by nonadiabatic coupling and energetics, that are strongly environment dependent, and (b) that in Xe matrices the Hg2 states correlating to the 3P1 and 3P0 asymptotic limits are stabilized in different configurations, as a result of the very different solvation properties of the atomic 3P1 and the 3P0 state. Further emission bands are found in the vicinity of the dimer transitions, which we attribute to Hg3 and to site effects on Hg2. In particular, electronically unrelaxed emission from excited states of Hg3 is reported.