Membrane systems are used increasingly for water treatment, recycling water from wastewater, during food processing, and energy production. They thus are a key technology to ensure water, energy, and food sustainability. However, biofouling, the build-up of microbes and their polymeric matrix, clogs these systems and reduces their efficiency. Realizing that a microbial film is inevitable, we engineered a beneficial biofilm that prevents membrane biofouling, limiting its own thickness by sensing the number of its cells that are present via a quorum-sensing circuit. The beneficial biofilm also prevents biofilm formation by deleterious bacteria by secreting nitric oxide, a general biofilm dispersal agent, as demonstrated by both short-term dead-end filtration and long-term cross-flow filtration tests. In addition, the beneficial biofilm was engineered to produce an epoxide hydrolase so that it efficiently removes the environmental pollutant epichlorohydrin. Thus, we have created a living biofouling-resistant membrane system that simultaneously reduces biofouling and provides a platform for biodegradation of persistent organic pollutants.