As rock inside the earth melts, its mass remains the same while its volume increases--producing a melt that is less dense than the surrounding rock. This lighter magma then rises toward the surface by virtue of its buoyancy. If the density of the magma between the zone of its generation and the surface is less than that of the surrounding and overlying rocks, the magma reaches the surface and erupts.