We propose a direct numerical method for the solution of an optimal control problem governed by a two-side space-fractional diffusion equation. The presented method contains two main steps. In the first step, the space variable is discretized by using the Jacobi–Gauss pseudospectral discretization and, in this way, the original problem is transformed into a classical integer–order optimal control problem. The main challenge, which we faced in this step, is to derive the left and right fractional differentiation matrices. In this respect, novel techniques for derivation of these matrices are presented. In the second step, the Legendre–Gauss–Radau pseudospectral method is employed. With these two steps, the original problem is converted into a convex quadratic optimization problem, which can be solved efficiently by available methods. Our approach can be easily implemented and extended to cover fractional optimal control problems with state constraints. Five test examples are provided to demonstrate the efficiency and validity of the presented method. The results show that our method reaches the solutions with good accuracy and a low central processing unit time.