We use fast synchrotron X-ray microtomography to understand three-phase flow in mixed-wet porous media to design either enhanced permeability or capillary trapping. The dynamics of these phenomena are of key importance in subsurface hydrology, carbon dioxide storage, oil recovery, food and drug manufacturing, and chemical reactors. We study the dynamics of a water-gas-water injection sequence in a mixed-wet carbonate rock. During the initial waterflooding, water displaced oil from pores of all size, indicating a mixed-wet system with local contact angles both above and below 90 •. When gas was injected, gas displaced oil preferentially with negligible displacement of water. This behavior is explained in terms of the gas pressure needed for invasion. Overall, gas behaved as the most nonwetting phase with oil as the most wetting phase; however, pores of all size were occupied by oil, water, and gas, as a signature of mixed-wet media. Thick oil wetting layers were observed, which increased oil connectivity and facilitated its flow during gas injection. A chase waterflooding resulted in additional oil flow, while gas was trapped by oil and water. Furthermore, we quantified the evolution of the surface areas and both Gaussian and the total curvature, from which capillary pressure could be estimated. These quantities are related to the Minkowski functionals which quantify the degree of connectivity and trapping. The combination of water and gas injection, under mixed-wet immiscible conditions, leads to both favorable oil flow and significant trapping of gas, which is advantageous for storage applications.