A wide range of applications in subsurface flow involve water, a nonaqueous phase liquid (NAPL) or oil, and a gas phase, such as air or CO2. The numerical simulation of such processes is computationally challenging and requires accurate compositional modeling of three-phase flow in porous media. In this work, we simulate for the first time three-phase compositional flow using higher-order finite element methods. Gravity poses complications in modeling multiphase processes because it drives countercurrent flow among phases. To resolve this issue, we propose a new method for the upwinding of three-phase mobilities. Numerical examples, related to enhanced oil recovery and carbon sequestration, are presented to illustrate the capabilities of the proposed algorithm. We pay special attention to challenges associated with gravitational instabilities and take into account compressibility and various phase behavior effects, including swelling, viscosity changes, and vaporization. We find that the proposed higher-order method can capture sharp solution discontinuities, yielding accurate predictions of phase boundaries arising in computational three-phase flow. This work sets the stage for a broad extension of the higher-order methods for numerical simulation of three-phase flow for complex geometries and processes.