The degenerate Blume-Emery-Griffiths model for martensitic transformations is extended by including both structural and magnetic degrees of freedom in order to elucidate premartensitic effects. Special attention is paid to the effect of the magnetoelastic coupling in Ni2MnGa. The microscopic model is constructed and justified based on the analysis of the experimentally observed strain variables and precursor phenomena. The description includes the (local) tetragonal distortion, the amplitude of the plane-modulating strain, and the magnetization. The model is solved by means of mean-field theory and Monte Carlo simulations. This last technique reveals the crucial importance of fluctuations in pretransitional effects. The results show that a variety of premartensitic effects may appear due to the magnetoelastic coupling. In the mean-held formulation this coupling is quadratic in both the modulation amplitude and the magnetization. For large values of the magnetoelastic coupling parameter we find a premartensitic first-order transition line ending in a critical point. This critical point is responsible for the existence of large premartensitic fluctuations which manifest as broad peaks in the specific heat, not always associated with a true phase transition. The main conclusion is that premartensitic effects result from the interplay between the softness of the anomalous phonon driving the modulation and the magnetoelastic coupling. In particular, the premartensitic transition occurs when such coupling is strong enough to freeze the involved mode phonon. The implication of the results in relation to the available experimental data is discussed.