We present a hardware agnostic error mitigation algorithm for near term quantum processors inspired by the classical Lanczos diagonalization method. This procedure can simultaneously reduce the impact of different sources of noise and potentially increase the quality of quantum circuit ansatzes employed in the solution of variational problems. Based on a solid mathematical framework, the proposed approach ensures consistency with the underlying physical principles, thus leading to reliable results and controllable fluctuations. Our protocol only requires an increase in the number of observables to be measured on the target circuit and, in contrast with other error mitigation schemes, it does not involve direct access to the hardware or the calibration of dedicated control pulses. Through numerical simulations and experiments on IBM Quantum superconducting hardware we demonstrate that this algorithm can be applied to a general class of quantum chemistry and physics models, crucially allowing for the reconstruction of non-trivial ground state properties and enhancing the accuracy of energy estimations beyond state-of-the-art results. *Work supported by the European Research Council, grant ERC-StG-Neupert-757867-PARATOP, and the Swiss National Science Foundation, grant 200021-179312.