Understanding the adsorption mechanisms of CO2 and N2 in illite, one of the main components of clay in shale, is important to improve the precision of the shale gas exploration and development. We investigated the adsorption mechanisms of CO2 and N2 in K-illite with varying pore sizes at the temperature of 333, 363 and 393 K over a broad range of pressures up to 30 MPa using the grand canonical Monte Carlo (GCMC) simulation method. The simulation system is proved to be reasonable and suitable through the discussion of the impact of cation dynamics and pore wall thickness. The simulation results of the excess adsorption amount, expressed per unit surface area of illite, is in general consistency with published experimental results. It is found that the sorption potential overlaps in micropores, leading to a decreasing excess adsorption amount with the increase of pore size at low pressure, and a reverse trend at high pressure. The excess adsorption amount increases with increasing pressure to a maximum and then decreases with further increase in the pressure, and the decreasing amount is found to increase with the increasing pore size. For pores with size greater larger than 2 nm, the overlap effect disappears.