The possibility of observing chemical reactions in ab initio molecular dynamics runs is severely hindered by the short simulation time accessible. We propose a new method for accelerating the reaction process, based on the ideas of the extended Lagrangian and coarse-grained non-Markovian metadynamics. We demonstrate that by this method it is possible to simulate reactions involving complex atomic rearrangements and very large energy barriers in runs of a few picoseconds.