Ab initio total-energy calculations have been performed to study the structural stability of Y1-xNi2. In the literature (Villars P and Calvert L D 1985 Pearson's Handbook of Crystallographic Data for Intermetallic Phases (Materials Park, OH: American Society for Metals)) YNi2 is often considered to show the cubic Laves phase structure, but x-ray diffraction experiments of Latroche et al (J. Less-Common Met. 161 L27) showed that YNi2 crystallizes in a superstructure of C15 with ordered Y vacancies with a stoichiometry of approximately Y0.95Ni2. The total-energy calculations for the superstructure and for the ideal C15 structure, as well as for the neighbouring phases in the Y-Ni phase diagram YNi and YNi3, confirm that the formation of the superstructure with Y vacancies is favoured against the formation of the pure C15 compound YNi2. The calculated relaxation of the atoms around the vacancies is also in good agreement with the experimental results (Latroche et al), demonstrating that the relaxation of strains in the Y sublattice is the driving mechanism for formation of vacancies. In addition, the electronic properties of the vacancy superstructure have been examined.