The structural and magnetic properties of Tm 2 Fe 17 and Tm 2 Fe 17 D 3.2 are investigated by means of x-raydiffraction, thermal, and ac magnetic susceptibility measurements, and iron-57 Mössbauer spectroscopy. Both compounds crystallize in a hexagonal P6 3 /mmc space group with a Th 2 Ni 17 -like structure. Deuterium insertion into Tm 2 Fe 17 induces large increases in the unit-cell volume, the saturation magnetization, and the ordering temperature. The unit-cell expansion is anisotropic, with a larger increase in the a lattice parameter than the c lattice parameter. A spin reorientation is observed at 90 K in Tm 2 Fe 17 in the temperature dependence of both the ac susceptibility and the Mössbauer spectra. Above and below 90 K, the iron magnetic moments are aligned within the basal plane and along the c-axis, respectively. An analysis of the Mössbauer spectra from 4.2 to 320 K yields the orientation of the iron magnetic moments and hyperfine fields, relative to the axes of the electricfield gradient tensor at the iron sites. As revealed by both the ac susceptibility measurements and the Mössbauer spectra, deuterium insertion into Tm 2 Fe 17 suppresses this spin reorientation, and in Tm 2 Fe 17 D 3.2 the iron magnetic moments are oriented within the basal plane of the unit cell from 4.2 to 295 K. The spin reorientation in Tm 2 Fe 17 results from a competition between the thulium and iron magnetic anisotropies. Below 90 K the thulium anisotropy dominates and favors an axial alignment of the spins. In contrast to carbon and nitrogen, deuterium insertion into Tm 2 Fe 17 decreases the influence of the thulium anisotropy, and in Tm 2 Fe 17 D 3.2 the iron anisotropy dominates and favors a basal alignment of the magnetic moments.