We present an exact theory of attenuation and dispersion of borehole Stoneley waves propagating along porous rocks containing spherical gas bubbles by using the Biot theory. An effective frequency-dependent fluid bulk modulus is introduced to describe the dynamic (oscillatory) behavior of the gas bubbles. The model includes viscous, thermal, and radiation damping. It is assumed that the gas pockets are larger than the pore size, but smaller than the wavelengths involved (mesoscopic inhomogeneity). A strong dependence of the attenuation of the Stoneley wave on gas fraction and bubble size is found. Attenuation increases with gas fraction over the complete range of studied frequencies . The dependence of the phase velocity on the gas fraction and bubble size is restricted to the lower frequency range. These results indicate that the interpretation of Stoneley wave properties for the determination of, for example, local permeability formation is not straightforward and could be influenced by the presence of gas in the near-wellbore zone. When mud-cake effects are included in the model, the same observations roughly hold, though dependence on the mud-cake stiffness is quite complex. In this case, a clear increase of the damping coefficient with saturation is predicted only at relatively high frequencies.