This paper is concerned with the mechanical response of a single-walled carbon nanotube. Euler-Bernoulli’s beam theory and Hamilton’s principle are employed to derive the set of governing differential equations. An efficient variational method is used to determine the solution of the problem and Legendre’s polynomials are used to define basis functions. Significance of using these polynomials is their orthonormal property as these shape functions convert mass and stiffness matrices either to zero or one. The impact of various parameters such as length, temperature and elastic medium on the buckling load is observed and the results are furnished in a uniform manner. The degree of accuracy of the obtained results is verified with the available literature, hence illustrates the validity of the applied method. Current findings show the usage of nanostructures in vast range of engineering applications. It is worth mentioning that completely new results are obtained that are in validation with the existing results reported in literature.