We present a dynamical study of the intermediate polar cataclysmic variable YY Dra based on time-series observations in the K band, where the donor star is known to be the major flux contributor. We covered the 3.97-h orbital cycle with 44 spectra taken between 2020 and 2022 and two epochs of photometry observed in 2021 March and May. One of the light curves was simultaneously obtained with spectroscopy to better account for the effects of irradiation of the donor star and the presence of accretion light. From the spectroscopy, we derived the radial velocity curve of the donor star metallic absorption lines, constrained its spectral type to M0.5–M3.5 with no measurable changes in the effective temperature between the irradiated and non-irradiated hemispheres of the star, and measured its projected rotational velocity vrot sin i = 103 ± 2 km s−1. Through simultaneous modelling of the radial velocity and light curves, we derived values for the radial velocity semi-amplitude of the donor star, K2 = 188−2+1 km s−1, the donor to white dwarf mass ratio, q = M2/M1 = 0.62 ± 0.02, and the orbital inclination, i = 42°−1°+2°. These binary parameters yield dynamical masses of M1 = 0.99−0.09+0.10 M⊙ and M2 = 0.62−0.06+0.07 M⊙ (68 per cent confidence level). As found for the intermediate polars GK Per and XY Ari, the white dwarf dynamical mass in YY Dra significantly differs from several estimates obtained by modelling the X-ray spectral continuum.