The object of this paper is to study spacetimes admitting W 2-curvature tensor. At first we prove that a W2-flat spacetime is conformally flat and hence it is of Petrov type O. Next, we prove that if the perfect fluid spacetime with vanishing W2-curvature tensor obeys Einstein's field equation without cosmological constant, then the spacetime has vanishing acceleration vector and expansion scalar and the perfect fluid always behaves as a cosmological constant. It is also shown that in a perfect fluid spacetime of constant scalar curvature with divergence-free W 2-curvature tensor, the energy-momentum tensor is of Codazzi type and the possible local cosmological structure of such a spacetime is of type I, D or O. © 2014 World Scientific Publishing Company.