Abstract We study virtual element methods (VEMs) for solving the obstacle problem, which is a representative elliptic variational inequality of the first kind. VEMs can be regarded as a generalization of standard finite element methods with the addition of some suitable nonpolynomial functions, and the degrees of freedom are carefully chosen so that the stiffness matrix can be computed without actually computing the nonpolynomial functions. With this special design, VEMS can easily deal with complicated element geometries. In this paper we establish a priori error estimates of VEMs for the obstacle problem. We prove that the lowest-order ($k=1$) VEM achieves the optimal convergence order, and suboptimal order is obtained for the VEM with $k=2$. Two numerical examples are reported to show that VEM can work on very general polygonal elements, and the convergence orders in the $H^1$ norm agree well with the theoretical prediction.