We study the collective dynamics of self-propelled rods in an inhomogeneous motility field. At the interface between two regions of constant but different motility, a smectic rod layer is spontaneously created through aligning interactions between the active rods, reminiscent of an artificial, semipermeable membrane. This "active membrane" engulfes rods which are locally trapped in low-motility regions and thereby further enhances the trapping efficiency by self-organization, an effect which we call "self-encapsulation." Our results are gained by computer simulations of self-propelled rod models confined on a two-dimensional planar or spherical surface with a stepwise constant motility field, but the phenomenon should be observable in any geometry with sufficiently large spatial inhomogeneity. We also discuss possibilities to verify our predictions of active-membrane formation in experiments of self-propelled colloidal rods and vibrated granular matter.