In this study, we present a three-phase, mixed-wet capillary bundle model with cross sections obtained from a segmented 2D rock image, and apply it to simulate gas-invasion processes directly on images of Bentheim sandstone after two-phase saturation histories consisting of primary drainage, wettability alteration, and imbibition. We calculate three-phase capillary pressure curves, corresponding fluid configurations, and saturation paths for the gas-invasion processes and study the effects of mixed wettability and saturation history by varying the initial water saturation after primary drainage and simulating gas invasion from different water saturations after imbibition. In this model, geometrically allowed gas/oil, oil/water, and gas/water interfaces are determined in the pore cross sections by moving two circles in opposite directions along the pore/solid boundary for each of the three fluid pairs separately. These circles form the contact angle with the pore walls at their front arcs. For each fluid pair, circle intersections determine the geometrically allowed interfaces. The physically valid three-phase fluid configurations are determined by combining these interfaces systematically in all permissible ways, and then the three-phase capillary entry pressures for each valid interface combination are calculated consistently on the basis of free-energy minimization. The valid configuration change is given by the displacement with the most favorable (the smallest) gas/oil capillary entry pressure. The simulation results show that three-phase oil/water and gas/oil capillary pressure curves are functions of two saturations at mixed wettability conditions. We also find that oil layers exist in a larger gas/oil capillary pressure range for mixed-wet conditions than for water-wet conditions, even though a nonspreading oil is considered. Simulation results obtained in sandstone rock sample images show that gas-invasion paths may cross each other at mixed-wet conditions. This is possible because the pores have different and highly complex, irregular shapes, in which simultaneous bulk-gas and oil-layer invasion into water-filled pores occur frequently. The initial water saturation at the end of primary drainage has a significant effect on the gas-invasion processes after imbibition. Small initial water saturations yield more-oil-wet behavior, whereas large initial water saturations show more-water-wet behavior. However, in both cases, the three-phase capillary pressure curves must be described by a function of two saturations. For mixed-wet conditions, in which some pores are water-wet and other pores are oil-wet, the gas/oil capillary pressure curves can be grouped into two curve bundles that represent the two wetting states. Finally, the results obtained in this work demonstrate that it is important to describe the pore geometry accurately when computing the three-phase capillary pressure and related saturation paths in mixed-wet rock.