A new force field and a hybrid Monte Carlo/molecular dynamics simulation method are developed to investigate the structural transition of zeolitic imidazolate framework-8 (ZIF-8) induced by N2 sorption. At a high loading (approximately 50 N2 molecules per unit cell), ZIF-8 shifts from low-loading (LL) to high-loading (HL) structure. A stepped sorption isotherm is predicted with three distinct regions, which agrees well with experimental data. The orientation of imidazolate rings and the motion of framework atoms exhibit sharp changes upon structural transition. Furthermore, pronounced changes are observed in various contributions to potential energies (including stretching, bending, torsional, van der Waals, and coulombic). The analysis of radial distribution functions between N2 and framework atoms suggests N2 interacts strongly with the imidazolate rings in ZIF-8. The simulation reveals that the structural transition of ZIF-8 is largely related to the reorientation of imidazolate rings, as attributed to the enhanced van der Waals interaction between N2 and imidazolate rings as well as the reduced torsional interaction of framework in the HL structure. This is the first molecular simulation study to describe the continuous structural transition of ZIF-8 and, it provides microscopic insight into the underlying mechanism.