The primary aim of this paper is to attenuate the tracking error of a fractionally damped nonlocal simply supported nanobeam with harmonic excitation using fractional order PID controller via genetic algorithm. The nonlinear ordinary differential equation of motion of the nanobeam is derived using D’Alembert’s principle via Eringen’s nonlocal continuum approach. Thereafter a time varying control force is implemented based on fractional order PID approach such that the closed loop response of the beam follows a desired trajectory of a predefined random signal. Following an objective function is conceived to search for the optimal values of fractional PID parameters in order to minimize the tracking error via genetic algorithm. A special filter known as Oustaloup filter is employed to carry out the fractional order integration and differentiation numerically. Comparing the performance of the closed loop system with PID and fractional PID, it shows that the latter yields better performance. © 2019, Springer-Verlag GmbH Germany, part of Springer Nature.