Atomically thin two-dimensional (2D) materials have long been considered as ideal platforms for developing separation membranes. However, it is difficult to generate uniform subnanometer pores over large areas on 2D materials. Herein, we report that the well-defined defect structure of monolayer MoS2, namely, eight-membered ring (8-MR) pores typically formed at the boundaries of two antiparallel grains, can serve as molecular sieves for efficient water/ion separation. The 8-MR pores (4.2 × 2.4 Å) in monolayer MoS2 allow rapid single-file water transport while rejecting various hydrated ions. Further, the density of grain boundaries and, consequently, the density of pores can be tuned by regulating the nucleation density and size of MoS2 grains during the chemical vapor deposition process. The optimized MoS2 membrane exhibited an ultrahigh water/NaCl selectivity of ~6.5 × 104 at a water permeance of 232 mol m−2 h−1 bar−1, outperforming the state-of-the-art desalination membranes. When used for direct hydrogen production from seawater by combining the forward osmosis and electrochemical water splitting processes, the membrane achieved ~40 times the energy conversion efficiency of commercial polymeric membranes. It also exhibited a rapid and selective proton transport behavior desirable for fuel cells and electrolysis. The bottom-up approach of creating precise pore structures on atomically thin films via grain boundary engineering presents a promising route for producing large-area membranes suitable for various applications.