A detailed analysis of the high-resolution infrared emission spectra of gaseous HgH2 and HgD2 in the 1200-2200 cm(-1) spectral range is presented. The nu3 antisymmetric stretching fundamental bands of 204HgH2, 202HgH2, 201HgH2, 200HgH2, 199HgH2, 198HgH2, 204HgD2, 202HgD2, 201HgD2, 200HgD2, 199HgD2, and 198HgD2, as well as a few hot bands involving nu1, nu2, and nu3 were analyzed rotationally, and spectroscopic constants were obtained. Using the rotational constants of the 000, 100, 01(1)0, and 001 vibrational levels, we determined the equilibrium rotational constants (B(e)) of the most abundant isotopologues, 202HgH2 and 202HgD2, to be 3.135325(24) cm(-1) and 1.569037(16) cm(-1), respectively, and the associated equilibrium Hg-H and Hg-D internuclear distances (re) are 1.63324(1) A and 1.63315(1) A, respectively. The re distances of 202HgH2 and 202HgD2 differ by about 0.005%, which can be attributed to the breakdown of the Born-Oppenheimer approximation.