A model for multicomponent gas separation using hollow-fiber membrane modules is presented that explicitly accounts for heating or cooling inside membrane permeators due to gas expansion. The model permits simulation of countercurrent contacting with permeate purging (or sweep). The numerical approach permits rapid and stable solutions for cases with many components, even when the mixture contains components with widely varying permeability coefficients. Simulation results are presented for natural-gas sweetening, a commercially significant application, using polymer permeation properties similar to those of a high-performance polyimide. For some conditions, temperature decreases from the feed to residue end of the module by as much as 40°C. As CO2 concentration in the feed increases or as stage cut increases, the temperature decrease from feed to residue increases. Relative to an isothermal case, expansion-driven cooling reduces stage cut at a given feed flow rate since gas permeability decreases with decreasing temperature. Neglect of expansion-driven cooling in natural-gas separation simulations can lead to large errors in estimating the amount of feed gas that can be treated to achieve a fixed residue composition. For 30% CO2 feed concentration, if the effective membrane thickness is halved, only a 20% increase (rather than almost a factor of 2) in the amount of gas that can be treated per unit area is obtained due to the impact of expansion-driven cooling on gas flux.