Microgrids (MG) are a branch of distributed energy sources, which often use renewable energies to produce electrical power and gives service to scattered loads in Island and Grid connected operation modes. Because of the uncertainties of power system and natural variations of the power produced by renewable energies, in this paper, fractional order PID (FOPID) is used to control the frequency of the microgrid. The output of a fuzzy system is the input of the FOPID controller which results in Fuzzy fractional order PID (FFOPID). Imperialist competitive algorithm (ICA) determines the optimal values of the controller parameters. Comparison of the proposed FFOPID with FOPID and classical PID controllers in several load changes scenarios shows a better performance of the proposed controller in terms of RMS, overshoot and undershoot, number of oscillations, and settling time of the frequency deviations. Simulations indicate the robust performance of the proposed controller against the changes of system parameters as well.