Available simulation methods, suitable to describe solid-solid phase transitions occurring upon increasing of presssure and/or temperature, are based on empirical interatomic potentials: this restriction reduces the predictive power, and thus the general usefulness of numeric simulations in this very relevant field. We present a new simulation scheme which allows, for the first time, the simulation of these phenomena with the correct quantum-mechanical description of interatomic forces and internal stress, along with the correct statistical mechanics of ionic degrees of freedom. The method is obtained by efficiently combining the Car-Parrinello method for ab- initio molecular dynamics with the Parrinello Rahman method to account for a variable cell shape. Within this scheme phase trasformations may spontaneously take place during the simulation with variation of external pressure and/or temperature. The validity of the method is demonstrated by simulating the metal-insulator transition in Silicon (from diamond structure to simple hexagonal structure) under high pressure.