The Y1-xMgxNi2.1 (x = 0, 0.1, 0.2, 0.3, 0.4, 0.5) alloys were prepared by sintering method in this work. The effect of Mg on structural transformation, hydrogen storage properties, and structural stability were investigated. It is found that with the increase of Mg substitution the abundance of (Y, Mg)Ni2 phase increases and the total amount of (Y, Mg)Ni3 and (Y, Mg)2Ni7 phases first increases and then decreases. Mg preferentially enters into the (Y, Mg)Ni2 phase. When the Mg content in (Y, Mg)Ni2 phase is higher than 0.2, the (Y, Mg)Ni2 phase forms and does not undergo hydrogen induced amorphization and disproportionation. The hydrogen storage capacity decreases owing to the transformation from (Y, Mg)Ni2 phase to the more stable (Y, Mg)Ni3 phase. When the Mg content in (Y, Mg)Ni2 phase increases to 0.5, the atomic radius ratio of A-side to B-side reduces to less than 1.37, there is no capacity attenuation after 50 cycles.