We study the instability mechanisms leading to slug flow formation in an inclined pipe subject to gravity forces. We use a phase-field approach, where the Cahn–Hillard model is used to model the interface. At the inlet, a stratified flow is imposed with a specified velocity profile. We validate our numerical results by comparing against previous theoretical models and by predicting the various flow regimes for horizontal and inclined pipes, including stratified flow, slug flow, dispersed bubble flow and annular flow. Subsequently, we focus on slug formation in an inclined pipe and connect its appearance with specific vortical dynamics. A two-dimensional channel geometry is first considered. When the heavy fluid is injected as the top layer, inverted vortex shedding emerges, which periodically impacts on the bottom wall, as it develops further downstream. The accumulation of heavy fluid in the bottom wall causes a back flow that induces rolling waves and interacts with the upstream jet. When the heavy fluid is placed as the bottom layer, the heavy fluid accumulates and initially forms a massive slug at the bottom region, close to the inlet. Subsequently, the heavy fluid slug starts to break into smaller pieces, some of which translate along the pipe. During the accumulation phase, a back flow forms also generating rolling waves. Occasionally, a rolling wave can reach the top of the pipe and form a new slug. To describe the generation of vorticity from the two-phase interface and pipe walls in the slug formation, we study the circulation dynamics and connect it with the resulting two-phase flow patterns. Finally, we conduct three-dimensional (3-D) simulations in a circular pipe and compare the differences between the 3-D flow patterns and its circulation dynamics against the 2-D simulation results.