In this investigation, a transient nonlinear dynamic analysis of nanobeams reinforced with carbon nanotubes, which is located on a nonlinear viscoelastic foundation under the impulse loading, is investigated. The boundary conditions of the nanobeam are considered as clamped-clamped, and the carbon nanotube is distributed in different distribution along the thickness of nanobeam. First, using the Hamiltonian method and taking advantage of the couple stress theory and considering the Von Karman relationship between strain and displacement, the differential equation governing for Euler–Bernoulli nanobeam is obtained. Then, by using the semi-exact method and the Galerkin's method, the displacement derivatives are separated from the time derivatives and the equation derived is solved using Runge–Kutta's numerical method. In order to confirm the equation and its solution, a comparative study is performed that shows an appropriate fitting between the results. Finally, the influence of parameters such as nonlinear coefficient of foundation, applied force, size effect, and type of nanotube distribution on the nonlinear frequency to linear frequency ratio and transient nanobeam dynamic response is investigated. A study is also conducted on the effect of foundation damping coefficient and the inclusion of nonlinear effects on the transient dynamic response when the nanobeam is under impulse load and resonance conditions. The results show that the nonlinear vibrational frequency of the nanobeam with the FG-X carbon nanotube distribution is the highest, and the FG-O carbon nanotubes distribution is the least.