We consider spacetime to be a connected real 4-manifold equipped with a Lorentzian metric and an affine connection. The 10 independent components of the (symmetric) metric tensor and the 64 connection coefficients are the unknowns of our theory. We introduce an action which is quadratic in curvature and study the resulting system of Euler-Lagrange equations. In the first part of the paper we look for Riemannian solutions, i.e. solutions whose connection is Levi-Civita. We find two classes of Riemannian solutions: 1) Einstein spaces, and 2) spacetimes with metric of a pp-wave and parallel Ricci curvature. We prove that for a generic quadratic action these are the only Riemannian solutions. In the second part of the paper we look for non-Riemannian solutions. We define the notion of a "Weyl pseudoinstanton" (metric compatible spacetime whose curvature is purely Weyl) and prove that a Weyl pseudoinstanton is a solution of our field equations. Using the pseudoinstanton approach we construct explicitly a non-Riemannian solution which is a wave of torsion in Minkowski space. We discuss the possibility of using this non-Riemannian solution as a mathematical model for the graviton or the neutrino.