Ferromagnetic Ni2MnGa has unique magnetoelastic properties. These are investigated by detailed computational studies of the phonon-dispersion curves for the non-modulated cubic L21 and tetragonal structures. For the L21 structure, a complete softening of the transverse-acoustic mode has been found around the wave vector q=[1/3,1/3,0](2π/a). The softening of this TA2 phonon mode leads to the premartensitic modulated superstructure observed experimentally. Further phonon anomalies, related to other structural transformations in Ni2MnGa, have also been found and examined. These anomalies appear to be due to the coupling of particular acoustic-phonon modes and optical modes derived from Ni.