In this paper, a computational technique based on the pseudo‐spectral method is presented for the solution of the optimal control problem constrained with elliptic variational inequality. In fact, our aim in this paper is to present a direct approach for this class of optimal control problems. By using the pseudo‐spectral method, the infinite dimensional mathematical programming with equilibrium constraint, which can be an equivalent form of the considered problem, is converted to a finite dimensional mathematical programming with complementarity constraint. Then, the finite dimensional problem can be solved by the well‐developed methods. Finally, numerical examples are presented to show the validity and efficiency of the technique. Copyright © 2017 John Wiley & Sons, Ltd.