The hydrogen storage properties and crystal structures of YMgNi4-based alloys, which were synthesized from (2 – x)YNi2 and xMgNi2 (0.6 ≤ x ≤ 1.2), were investigated by pressure–composition–temperature measurements and powder neutron diffraction at a deuterium gas pressure to understand the hydrogen absorption and desorption reactions viewed from atomic arrangements around H atoms. Reducing the amounts of MgNi2, which was utilized as a Mg source in YMgNi4-based alloys, has been observed to lower the hydrogen absorption and desorption pressures and increase the hydrogen storage capacities. However, the reversible hydrogen capacity attained a maximum value of 1.2 mass % at x = 0.8 because of the formation of a thermodynamically stable hydride in which hydrogen was not released at x = 0.6. In the case of x = 0.6, the presence of excessive Y atoms around the H atoms in the hydrogen-absorbed phase would lead to the formation of a hydride with stronger interaction between Y and H because of the affinity between them. Moreover, the presence of small amounts of D atoms with short interatomic D–D distances (1.6 and 1.9 Å) in the deuterium-absorbed phase (Y0.81Mg1.19Ni4.00D3.35 and Y1.06Mg0.94Ni4.00D3.86) at <5 MPa and 323 K was proposed by the crystal structural investigations. The D atoms with short D–D interatomic distances were located in the same local atomic arrangements of D atoms in a deuterium-absorbed phase, which were formed at a higher-pressure range, and had higher hydrogen storage capacities than the deuterium-absorbed phases in this study.