In this paper, we study the space-time spectral approximation to an optimal control problem governed by the time fractional diffusion equation with an integral constraint on the state variable. The optimality conditions of the exact and discrete optimal control systems are derived in virtue of the Kuhn-Tucker condition. Then some a priori error estimates showing the spectral accuracy are obtained. Furthermore, an iterative algorithm based on the gradient projection optimization method using Galerkin spectral approximation is proposed to solve the discrete system. Finally, some numerical examples are performed to verify the theoretical results.