This study addresses the dynamic stability of an Euler–Bernoulli nanobeam under time-dependent axial loading based on the nonlocal strain gradient theory (NSGT) and considering the surface stress effects. The studied nanobeam cross-section was rectangular, and simply-supported boundary conditions were assumed. Moreover, a uniform thermal gradient was applied to the nanobeam. The elastic medium was modeled based on the Pasternak theory. The strain–displacement relations were derived using the Von Kármán equations. The governing equations were obtained by the energy method and applying the Hamilton's principle. Furthermore, the Bolotin and Incremental Harmonic Balance (IHB) methods were used to solve the differential equations. This study investigates the impact of such parameters as the small-scale parameter, the material length scale, surface effects, elastic medium parameters, temperature variations, geometry, and the static loading factor on the Dynamic Instability Region (DIR). The results are suggestive of the shift of the DIR to lower frequency zone by increasing the small-scale Eringen's nonlocal theory parameter, whereas an increase in the material length scale from the strain gradient theory moves the region to higher frequencies. In case the said parameters are equal, the result conforms to the classical beam theory. In addition, assuming a Pasternak medium and taking into account the effects of surface stress (Young's modulus and the residual stress of the surface) shifts the DIR to higher frequencies, whereas applying a compressive static load moves the region to lower frequencies. Moreover, depending on the thermal expansion coefficient of the medium, temperature variations can also displace the DIR.