The storage and separation of H2 and CO2 are investigated in a highly porous ionic rht metal−organic framework (rht-MOF) using molecular simulation. The rht-MOF possesses a cationic framework and charge-balancing extraframework NO3− ions. Three types of unique open cages exist in the framework: rhombicuboctahedral, tetrahedral, and cuboctahedral cages. The NO3− ions exhibit small mobility and are located at the windows connecting the tetrahedral and cuboctahedral cages. At low pressures, H2 adsorption occurs near the NO3− ions that act as preferential sites. With increasing pressure, H2 molecules occupy the tetrahedral and cuboctahedral cages and the intersection regions. The predicted isotherm of H2 at 77 K agrees well with the experimental data. The H2 capacity is estimated to be 2.4 wt % at 1 bar and 6.2 wt % at 50 bar, among the highest in reported MOFs. In a four-component mixture (15:75:5:5 CO2/H2/CO/CH4) representing a typical effluent gas of H2 production, the selectivity of CO2/H2 in rht-MOF decreases slightly with increasing pressure, then increases because of cooperative interactions, and finally decreases as a consequence of entropy effect. By comparing three ionic MOFs (rht-MOF, soc-MOF, and rho-ZMOF), we find that the selectivity increases with increasing charge density or decreasing free volume. In the presence of a trace amount of H2O, the interactions between CO2 and NO3− ions are significantly shielded by H2O; consequently, the selectivity of CO2/H2 decreases substantially.