Rapid implementation of large-scale carbon capture and storage is necessary to limit global warming this century. Amongst various CO2 storage sites, depleted oilfields provide an immediate option since injection infrastructure is in place and there is an economic benefit from enhanced oil recovery. To design secure carbon storage in oilfields, we need to understand how the three fluid phases – CO2, oil, and water – flow simultaneously in the microscopic pore spaces of the reservoir. In this PhD thesis, we present a novel methodology to study three-phase flow in porous media, at various wettability and gas-oil miscibility conditions, using X-ray microtomography. The use of X-ray imaging allows for a complete investigation of the pore-scale properties that control flow and trapping in three-phase flow, i.e., wettability order, spreading and wetting layers, and double/multiple displacement events. In addition, our advanced experimental and image analysis techniques permit access to key petrophysical properties including fluid saturations, capillary pressures, three-phase relative permeabilities and pore occupancy maps. The three-phase experiments we perform include unsteady-state and steady-state flow conditions and employ both laboratory-based and synchrotron X-ray sources. While laboratory-based scanners image the fluid configurations at the end of displacement or at steady-state equilibrium, synchrotron scanners allow us to capture the pore-scale dynamics during displacement. First, we investigate unsteady-state three-phase flow under near-miscible gas-oil conditions – where the gas-oil interfacial tension is ≤ 1 mN/m – and show that fluids display a unique behavior compared to that seen at immiscible conditions where the interfacial tension is larger by one order of magnitude. In a water-wet system, at near-miscible conditions, gas and oil appear to become neutrally wetting to the surface. This prevents oil from spreading in layers sandwiched between gas and water; the strict wettability order – water-oil-gas, from most to least wetting – seen at immiscible conditions breaks down. This facilitates the flow of oil and gas along the same path in the pore space occupying the centre of the larger pores, while water remains connected in wetting layers in the corners. While this behaviour is desirable for oil recovery, it can impact the storage security as oil can no longer trap CO2. In a weakly oil-wet system, the wettability order shifts from oil-water-gas to oil-gas-water as we move from immiscible to near-miscible conditions. As CO2 becomes the intermediate-wet phase, at near-miscible conditions, it forms spreading layers in the corners of the pore space. The existence of CO2 in spreading layers has huge implications on the storage design since its flow conductance is naturally restricted which implies that subsequent water injection is not necessary to prevent CO2 migration and escape. Next, we show that reservoir rocks can undergo severe wettability alterations rendering them strongly oil-wet. Under unsteady-state flow at immiscible conditions, we observe the predicted, but hitherto unreported, three-phase wettability order in strongly oil-wet rocks, where water occupies the largest pores, oil the smallest, while CO2 occupies pores of intermediate size. Although this wettability order is the same as that seen in a weakly oil-wet rock at near-miscible conditions, the pore-scale fluid configurations are different. While CO2, the intermediate-wet phase, spreads in layers at near-miscible conditions, at immiscible conditions, it exists in the pore space as disconnected ganglia. The existence of CO2 in disconnected clusters, at immiscible conditions, allows for the capillary trapping of gas by oil in the centre of the pores which is not possible when CO2 forms layers. However, capillary trapping of gas by water is still impossible at both miscibility conditions since gas is more wetting to the surface than water. This implies that water re-injection to disconnect the CO2 in the reservoir is unnecessary in both cases. Using a synchrotron X-ray source, we then investigate the invasion pattern during unsteady-state two- and three-phase flow – water injection followed by gas – in a strongly oil-wet reservoir rock at immiscible conditions. During water injection, we observe that the displacement of oil by water is a drainage-like process, where water advances as a connected front displacing oil in the centre of the pores, confining the oil to wetting layers. The displacement is an invasion percolation process, where throats, the restrictions between pores, fill in order of size, with the largest available throats filled first. Moreover, we observe drainage associated pore-filling dynamics including Haines jumps and snap-off events. Subsequently, during gas injection, a distinct invasion pattern is observed for three-phase flow, where gas progresses through the pore space in the form of disconnected clusters mediated by double and multiple displacement events. Gas advances in a process we name three-phase Haines jumps, during which gas re-arranges its configuration in the pore space, retracting from some regions to enable the rapid filling of multiple pores. The gas retraction leads to a permanent disconnection of gas ganglia, which do not reconnect as gas injection proceeds. Lastly, we develop a novel experimental approach to investigate steady-state three-phase flow using pore-scale X-ray imaging. Our newly designed flow cell allows for the differential pressure across the system to be measured, enabling for the simultaneous determination of three-phase relative permeability and capillary pressure. We first investigate steady-state three-phase flow in a water-wet system at immiscible conditions, where the wettability order is water-oil-gas, from most to least wetting. We discover a unique flow dynamics where gas is disconnected across the system despite its continuous injection; gas flows by periodically opening critical flow pathways in intermediate-sized pores. We observe intermittent gas-oil and oil-water behaviour even under capillary-dominated conditions in three-phase flow. At steady-state conditions, it was impossible to displace the trapped gas in our water-wet system since it is double capillary trapped by spreading, oil, and wetting, water, layers. Gas has the lowest relative permeability in the pore space, while oil the highest. Next, we study steady-state three-phase flow in a mixed-wet system at immiscible conditions with an oil-water-gas wettability order. We observe that the gas flow is disconnected, similar to the water-wet system. However, intermittency was more pronounced in the mixed-wet system. The oil relative permeability was the highest in the pore space followed by water, then gas like the water-wet system. The impact of saturation history on gas and water relative permeabilities was larger than its impact on the oil relative permeability. Surprisingly, there was no gas trapping in the system due to its mixed-wet nature which prevents oil and water from completely surrounding the gas phase. This thesis presents an effective and universal methodology to study three-phase flow in porous media at the pore-scale using X-ray microtomography. While the results were strictly discussed in the context of subsurface storage and recovery, it can have implications for many other engineering applications including microfluidic devices, packed bed chemical reactors and catalysis. The findings of this thesis can be used to advise on the design of the optimal conditions to store as much CO2 as possible while maximizing oil production in CO2-enhanced oil recovery projects. Open Access