We study the evolution of embedded clusters. The equations of motion of the stars in the cluster are solved by direct N-body integration while taking the effects of stellar evolution and the hydrodynamics of the natal gas content into account. The gravity of the stars and the surrounding gas are coupled self-consistently to allow the realistic dynamical evolution of the cluster. While the equations of motion are solved, a stellar evolution code keeps track of the changes in stellar mass, luminosity and radius. The gas liberated by the stellar winds and supernovae deposits mass and energy into the gas reservoir in which the cluster is embedded. We examine cluster models with 1000 stars, but we varied the star formation efficiency (between 0.05 and 0.5), cluster radius (0.1–1.0 pc), the degree of virial support of the initial population of stars (0–100 per cent) and the strength of the feedback. We find that an initial star fraction M★/Mtot > 0.05 is necessary for cluster survival. Survival is more likely if gas is not blown out violently by a supernova and if the cluster has time to approach virial equilibrium during outgassing. While the cluster is embedded, dynamical friction drives early and efficient mass segregation in the cluster. Stars of m≳ 2 M⊙ are preferentially retained, at the cost of the loss of less massive stars. We conclude that the degree of mass segregation in open clusters such as the Pleiades is not the result of secular evolution but a remnant of its embedded stage.