We propose a simple model that provides a dynamical cancellation mechanism of the vacuum energy density appearing either in the form of a bare cosmological constant, quantum fluctuations of matter fields or the result of phase transitions. This `conformal compensator model' is based on a conformal coupling $A(\varphi)$ between the Einstein and the Jordan frames. This couples a second scalar field $\lambda$ to the trace of the matter energy-momentum tensor, including the bare cosmological constant, and serves as a dynamical Lagrange multiplier. As a result, the scalar $\lambda$ relaxes to a value which cancels the contributions from the vacuum energy density to the Friedmann equation, and adjusts itself to changes of the vacuum energy density after matter phase transitions. This circumvents Weinberg's theorem through the time dependence of the background scalar field $\varphi$. The radiation era, where the vacuum energy is annulled, is recovered in a natural manner. It is also possible to recover the matter era, via a tracking of the matter energy density by the scalar field, as well as the inflationary and dark energy eras, which correspond to regimes where the cancellation mechanism becomes inefficient. This suggests that inflation, dark energy, and the annulation of the vacuum energy density, could be related to the same mechanism. In this setting, the usual fine-tuning of the vacuum energy is avoided, although the onset of the dark energy era at the appropriate time is not explained.