A novel method for crystal structure prediction, based on metadynamics and evolutionary algorithms, is presented here. This technique can be used to produce efficiently both the ground state and metastable states easily reachable from a reasonable initial structure. We use the cell shape as collective variable and evolutionary variation operators developed in the context of the USPEX method to equilibrate the system as a function of the collective variables. We illustrate how this approach helps one to find stable and metastable states for AlSiO, SiO, MgSiO, and carbon. Apart from predicting crystal structures, the new method can also provide insight into mechanisms of phase transitions.