A doubly interpenetrated magnesium-based porous metal-organic framework exhibits thermal stability up to 500 degrees C and selective gas sorption properties for H2 and O2 gases over N2, and CO2 gas over CH4.