Based on the competitive adsorption of CH 4 and CO 2 , molecular dynamics (MD) and Grand Canonical Monte Carlo (GCMC) are used to study the mechanism of increasing shale gas recovery by carbon dioxide injection. The influence of different factors on the diffusion capacity of CH 4 in unrestricted space and restricted space is analyzed, and the diffusion capacities of CH 4 and CO 2 in shale nanopores are compared. Under different conditions, the difference in the sorption amount and sorption heat of CH 4 and CO 2 is studied, and the displacement simulation of CH 4 and CO 2 is conducted. The obtained results show that the diffusion capacity of CH 4 in restricted space is much smaller than that in unrestricted space, and the difference between them is related to temperature, pressure, and pore size. When pressure exceeds 10 MPa, the difference gradually decreases. The diffusion capacity of CO 2 is weaker than that of CH 4 under the same conditions, which contributes to the retention of CO 2 . There is a competitive sorption relationship between CH 4 and CO 2 . The sorption amount and sorption heat of CH 4 and CO 2 are affected by the combination of pressure, temperature, density ratio, pore size, and mineral type. The adsorption capacity of CO 2 is much higher than that of CH 4 . When sorption conditions are more favorable, the adsorption difference between CH 4 and CO 2 will become larger. In shale nanopores, CO 2 can replace CH 4 that is adsorbed on the pore surface to improve shale gas recovery.