It is well-known that rotating nanobeams can have different dynamic and stability responses to various types of loadings. In this research, attention is focused on studying the effects of magnetic field, surface energy and compressive axial load on the dynamic and the stability behavior of the nanobeam. For this purpose, it is assumed that the rotating nanobeam is located in the nonuniform magnetic field and subjected to compressive axial load. The nonlocal elasticity theory and the Gurtin-Murdoch model are applied to consider the effects of inter atomic forces and surface energy effect on the vibration behavior of rotating nanobeam. The vibration frequencies and critical buckling loads of the nanobeam are computed by the differential quadrature method (DQM). Then, the numerical results are testified with those results are presented in the published works and a good correlation is obtained. Finally, the effects of angular velocity, magnetic field, boundary conditions, compressive axial load, small scale parameter and surface elastic constants on the dynamic and the stability behavior of the nanobeam are studied. The results show that the magnetic field, surface energy and the angular velocity have important roles in the dynamic and stability analysis of the nanobeams.