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 [Oganov, Glass, J. Chem. Phys., 2006, 124, 244704; Lyakhov et al., Comp. Phys. Comm., 2010, 181, 1623; Oganov et al., Acc. Chem. Res., 2011, 44, 227] to equilibrate the system as a function of the collective variables. We illustrate how this concept helps one to find stable and metastable states for Al2SiO5, SiO2, MgSiO3, and carbon. Apart from predicting crystal structures, the new method can also provide insight into the mechanisms of phase transitions.