The adsorption behavior of NH4+ and Mg2+ at kaolinite surfaces was investigated by using molecular dynamics (MD) simulations, considering the factors such as ion concentration, NH4+/Mg2+ mixing ratio, and layer charge of kaolinite. The results showed that the increase in ion concentration did not affect the adsorption modes of NH4+ and Mg2+ ions but promote the increase in the adsorption capacity. The total adsorption capacities of Mg2+ and NH4+ were 3.25 × 10−6 and 2.85 × 10−6 μmol·mm−2 at the ion concentration of 1.5 mol·L−1, respectively. When NH4+ and Mg2+ were co‐adsorbed, they could inhibit the adsorption of each other at the surface of kaolinite, except that the inner‐sphere (IS) adsorption of NH4+ at aluminum hydroxyl (Al–OH) surface could be enhanced by the presence of Mg2+. Both NH4+ and Mg2+ tended to adsorb at the siloxane (Si–O) surface of kaolinite rather than Al–OH surface. When layer charge occurred in kaolinite, a small number of Mg2+ began to adsorb in the IS complexes at 1.7 and 2.3 Å above the Al and O atoms of the lattice‐substituted tetrahedra of the Si–O surface, and at 1.7 Å above the hexahedra of the Al–OH surface. However, most of NH4+ were adsorbed in IS complexes at 1.7 Å above the center of the oxygen six‐membered ring of the Si–O surface and above the hexahedron of the Al–OH surface. The adsorption capacity of Mg2+ changed little with the increase of layer charge density, while the IS and total adsorption capacity of NH4+ increased significantly.