Heavy metal ions from water and wastewater are non-biodegradable and tend to accumulate in the soil and living organisms, polluting the environment and causing serious health hazards in humans. Therefore, effective treatment of heavy metal ions in aqueous media is critical for public health and environmental sustainability. In this paper, we employ molecular dynamics simulations to investigate the removal efficiency of heavy metal cations (Cd2+, Hg2+, and Pb2+) by a zirconium phosphonate based metal-organic framework (MOF) filter and also to explore its underlying molecular mechanism. Our results show that the inherently porous MOF filter shows a superior efficiency (>95%) in the removal of heavy metal cations under a wide range of pressures (50 to 350 MPa). This superior efficiency is achieved by absorption and blockage of these cations within MOF filters via two distinct binding patterns, "loose mode" with water molecules as a mediator, and ''tight mode'' without any mediating molecules. These findings provide new insight for applying the MOF nanopores as potential filters in the removal of hazardous heavy metal cations in the environment.