Although multiple methods have been developed to detect or remove trace Pb2+ ions, performing both roles together still remains a challenging task. In this study, we present a gating membrane with poly(N-isopropylacrylamide-co-acryloylamidobenzo-18-crown-6) (poly(NIPAM-co-AAB18C6)) copolymer chains as functional gates, in which a large amount of crown ether units are introduced as Pb2+ receptors by a two-step method. This gating membrane can be used in water treatment for selective detection and removal of trace Pb2+ ions. The gating action of the synthesized membrane for detecting trace Pb2+ ions is significant and reproducible. By simply changing the operation temperature, effective removal of trace Pb2+ ions and efficient membrane regeneration are achieved. This gating membrane has high potential for various industrial and agricultural applications, such as online detection and timely treatment of trace Pb2+ ions in wastewater discharge, analysis for water quality, and remediation and protection of soil.