Despite substantial advances in crystal structure determination methodology for polycrystalline materials, some problems have remained intractable. A case in point is the zeolite catalyst IM-5, whose structure has eluded determination for almost 10 years. Here we present a charge-flipping structure-solution algorithm, extended to facilitate the combined use of powder diffraction and electron microscopy data. With this algorithm, we have elucidated the complex structure of IM-5, with 24 topologically distinct silicon atoms and an unusual two-dimensional medium-pore channel system. This powerful approach to structure solution can be applied without modification to any type of polycrystalline material (e.g., catalysts, ceramics, pharmaceuticals, complex metal alloys) and is therefore pertinent to a diverse range of scientific disciplines.