Multiphase flow in porous media is important in many natural and industrial processes, including geologic CO2 sequestration, enhanced oil recovery, and water infiltration into soil. Although it is well known that the wetting properties of porous media can vary drastically depending on the type of media and pore fluids, the effect of wettability on multiphase flow continues to challenge our microscopic and macroscopic descriptions. Here, we study the impact of wettability on viscously unfavorable fluid–fluid displacement in disordered media by means of high-resolution imaging in microfluidic flow cells patterned with vertical posts. By systematically varying the wettability of the flow cell over a wide range of contact angles, we find that increasing the substrate’s affinity to the invading fluid results in more efficient displacement of the defending fluid up to a critical wetting transition, beyond which the trend is reversed. We identify the pore-scale mechanisms—cooperative pore filling (increasing displacement efficiency) and corner flow (decreasing displacement efficiency)—responsible for this macroscale behavior, and show that they rely on the inherent 3D nature of interfacial flows, even in quasi-2D media. Our results demonstrate the powerful control of wettability on multiphase flow in porous media, and show that the markedly different invasion protocols that emerge—from pore filling to postbridging—are determined by physical mechanisms that are missing from current pore-scale and continuum-scale descriptions.