This article aims to study the buckling and free vibrational behavior of axially functionally graded (AFG) nanobeam under thermal effect for the first time. The temperature is considered to be constant and variable along thickness and different boundary conditions. The governing equation is developed using the Hamilton’s principle considering the axial force. The Euler–Bernoulli beam theory is used to model the nanobeam, and Eringen’s nonlocal elasticity theory is utilized to consider the nano-size effect. The generalized differential quadrature method (GDQM) is used to solve the equations. The small-scale parameter, AFG power index, thermal distribution, different functions of temperature increase for different boundary conditions are given in detail.