In nature, biological compartments such as cells rely on dynamically controlled permeability for matter exchange and complex cellular activities. Likewise, the ability to engineer compartment permeability is crucial for in vitro systems to gain sustainability, robustness, and complexity. However, rendering in vitro compartments such a capability is challenging. Here, a facile strategy is presented to build permeability-configurable compartments, and marked advantages of such compartmentalization are shown in reconstituting sustained synthetic biology systems in vitro. Through microfluidics, the strategy produces micrometer-sized layered microgels whose shell layer serves as a sieving structure for biomolecules and particles. In this configuration, the transport of DNAs, proteins, and bacteriophages across the compartments can be controlled an guided by a physical model. Through permeability engineering, a compartmentalized cell-free protein synthesis system sustains multicycle protein production; ≈100000 compartments are repeatedly used in a five-cycle synthesis, featuring a yield of 2.2mg mL-1 . Further, the engineered bacteria-enclosing compartments possess near-perfect phage resistance and enhanced environmental fitness. In a complex river silt environment, compartmentalized whole-cell biosensors show maintained activity throughout the 32 h pollutant monitoring. It is anticipated that permeability-engineered compartmentalization should pave the way for practical synthetic biology applications such as green bioproduction, environmental sensing, and bacteria-based therapeutics.