We study the gas–water transient imbibition and drainage processes in two-dimensional nanoporous media using our recently developed lattice Boltzmann model. To describe the microscopic molecular interactions, the model employs a pseudopotential that correlates the local density and interaction strength to perform simulation at a mesoscopic scale. The primary interest is ganglia dynamics in the nanoporous media affected by fluid and geometrical properties of the porous structure. We performed sensitivity analyses on the fluid and rock characteristics such as the Euler number, gas–water interfacial area, water film area, capillary pressure, pore size distribution, specific surface area, and wettability. The simulation results revealed the fingering nature of the nonwetting phase. In the imbibition process, the flow pathway of water results in isolated and trapped gas bubble clusters because of the strong attraction between water and solid surfaces. In the drainage process, the pressure difference between the gas phase and the water phase depends on both the capillary pressure and the disjoining pressure due to the presence of water film. Pore topography and specific surface area control the continuity of the fluid phases in the imbibition process. In nonwet systems, the water phase starts fingering in the nanoporous system. The present work elucidates the microscopic ganglia dynamics of gas–water two-phase flow in nanoporous media. The microscopic scale details will help establish the macroscopic flow equation to accurately predict two-phase flow in shale gas, tight oil, and caprock seals.