Underground hydrogen (H2) storage has become increasingly popular in recent years; however, H2 leakage is a critical concern. A conventional reservoir is sealed by a dense caprock; the long-chain hydrocarbons cannot escape through the caprock because of the complex molecular structure and large molecular size, but H2 leakage can still occur, particularly through the nanopores of the caprock. In this study, we investigate the H2 leakage problem using the molecular dynamics (MD) and MD–Monte Carlo (MDMC) methods. The results of our MDMC algorithm concur with the MD simulation results, indicating that the MDMC algorithm can feasibly predict the H2 leakage process. Caprock defects are repaired by water (H2O) clusters owing to the hydrogen bonding and adsorption of H2O on the caprock surface. Methane (CH4) forms an absorption layer on the caprock, inhibiting the probability of contact between H2 and the rock surface. We further explain the spatial distribution of different gas components using their potential energies and interaction forces. The molecular sealing mechanism is also proposed accordingly, and the H2O cluster and CH4 adsorption layer form the double barrier for H2 leakage. The evaporation of H2O at high temperatures weakens the stability of the H2O cluster, and smaller pore sizes (<10.0 Å) within the caprock prevent H2 leakage. H2 leakage can be further inhibited by increasing the H2O content in a H2 storage project. Thus, a specific amount of H2O and CH4 gas can alleviate the H2 leakage problem.