Automatic voltage regulator (AVR) is an equipment maintaining the terminal voltage of generators to a specific level all the time and under any load conditions. Many controllers for AVR system are designed based on a linearized normal model of AVR system and they are not robust enough against uncertainties such as parameter variation and load change in the system. In this paper, a gray PID (GPID) controller is designed for AVR system. The GPID controller consists of two parts, i.e. a conventional PID controller together with a gray compensation controller. In GPID controller, gray GM (0, N) model is used to estimate the uncertainties online, and a gray compensation controller is constructed according the estimation results to eliminate the effect of uncertainties. To further improve its performance, the GPID controller's parameters are optimized through a new evolutionary algorithm, i.e., imperialist competitive algorithm (ICA). The proposed GPID controller can effectively deal with the uncertainties in AVR system. Simulation results illustrate its effectiveness of the proposed control scheme.