Context. The hydrogen deuteride (HD) molecule is an important deuterium tracer in astrophysical studies. The atmospheres of gas giants are dominated by molecular hydrogen, and the simultaneous observation of H2 and HD lines provides reliable information on the D/H ratios on these planets. The reference spectroscopic parameters play a crucial role in such studies. Under the thermodynamic conditions encountered in these atmospheres, spectroscopic studies of HD require not only the knowledge of line intensities and positions but also accurate reference data on pressure-induced line shapes and shifts. Aims. Our aim is to provide accurate collision-induced line-shape parameters for HD lines that cover any thermodynamic conditions relevant to the atmospheres of giant planets, namely any relevant temperature, pressure, and perturbing gas composition (the H2–He mixture). Methods. We performed quantum-scattering calculations on our new, highly accurate ab initio potential energy surface (PES), and we used scattering S matrices obtained in this way to determine the collision-induced line-shape parameters. We used cavity ring-down spectroscopy to validate our theoretical methodology. Results. We report accurate collision-induced line-shape parameters for the pure rotational R(0), R(1), and R(2) lines, the most relevant HD lines for investigations of the atmospheres of the giant planets. Besides the basic Voigt-profile collisional parameters (i.e., the broadening and shift parameters), we also report their speed dependences and the complex Dicke parameter, which can influence the effective width and height of the HD lines up to almost a factor of 2 for giant planet conditions. The sub-percent-level accuracy reached in this work is a considerable improvement over previously available data. All the reported parameters (and their temperature dependences) are consistent with the HITRAN database format, hence allowing for the use of the HITRAN Application Programming Interface (HAPI) for generating the beyond-Voigt spectra of HD.