The behavior of gas bubbles in porous media includes bubble nucleation and growth, migration, coalescence, and trapping. These processes are significantly affected by the pore-scale characteristics and heterogeneity of the sediment. In this study, experiments are performed using a microfluidic chip in which different gas bubble behavior mechanisms are observed. Based on the microscale experiments, eight major gas bubble behavior mechanisms are identified. In addition, a mesoscale experiment is designed and performed to study the impacts of soil layering and heterogeneity on the formation and distribution of biogenic gas generation via denitrification. The results show that the pore-scale characteristics of soil significantly affect the distribution and migration pattern of biogenic gas bubbles. As a result, the water saturation may vary locally between fully saturated (in fine sand), to about 80% in zones where the gas is allowed to migrate freely (coarse sand), to even close to 0% in the zone where the gas gets trapped under layers with higher air entry value.