It is sometimes speculated that the sign problem that afflicts many quantum field theories might be reduced or even eliminated by choosing an alternative domain of integration within a complexified extension of the path integral (in the spirit of the stationary phase integration method). In this paper we start to explore this possibility somewhat systematically. A first inspection reveals the presence of many difficulties but - quite surprisingly - most of them have an interesting solution. In particular, it is possible to regularize the lattice theory on a Lefschetz thimble, where the imaginary part of the action is constant and disappears from all observables. This regularization can be justified in terms of symmetries and perturbation theory. Moreover, it is possible to design a Monte Carlo algorithm that samples the configurations in the thimble. This is done by simulating, effectively, a five dimensional system. We describe the algorithm in detail and analyze its expected cost and stability. Unfortunately, the measure term also produces a phase which is not constant and it is currently very expensive to compute. This residual sign problem is expected to be much milder, as the dominant part of the integral is not affected, but we have still no convincing evidence of this. However, the main goal of this paper is to introduce a new approach to the sign problem, that seems to offer much room for improvements. An appealing feature of this approach is its generality. It is illustrated first in the simple case of a scalar field theory with chemical potential, and then extended to the more challenging case of QCD at finite baryonic density.