The promise of ultrapermeable polymers, such as poly(trimethylsilylpropyne) (PTMSP), for reducing the size and increasing the efficiency of membranes for gas separations remains unfulfilled due to their poor selectivity. We report an ultrapermeable polymer of intrinsic microporosity (PIM-TMN-Trip) that is substantially more selective than PTMSP. From molecular simulations and experimental measurement we find that the inefficient packing of the two-dimensional (2D) chains of PIM-TMN-Trip generates a high concentration of both small (<0.7 nm) and large (0.7-1.0 nm) micropores, the former enhancing selectivity and the latter permeability. Gas permeability data for PIM-TMN-Trip surpass the 2008 Robeson upper bounds for O2/N2, H2/N2, CO2/N2, H2/CH4 and CO2/CH4, with the potential for biogas purification and carbon capture demonstrated for relevant gas mixtures. Comparisons between PIM-TMN-Trip and structurally similar polymers with three-dimensional (3D) contorted chains confirm that its additional intrinsic microporosity is generated from the awkward packing of its 2D polymer chains in a 3D amorphous solid. This strategy of shape-directed packing of chains of microporous polymers may be applied to other rigid polymers for gas separations.