Optimizing the morphology of metal halide perovskite films is an important way to improve the performance of solar cells1when these materials are used as light harvesters2, because film homogeneity is correlated with photovoltaic performance3. Many device architectures and processing techniques have been explored with the aim of achieving high-performance devices4, including single-step deposition5, sequential deposition6,7and anti-solvent methods1,8. Earlier studies have looked at the influence of reaction conditions on film quality3, such as the concentration of the reactants9,10and the reaction temperature11. However, the precise mechanism of the reaction and the main factors that govern it are poorly understood. The consequent lack of control is the main reason for the large variability observed in perovskite morphology and the related solar-cell performance2,3. Here we show that light has a strong influence on the rate of perovskite formation and on film morphology in both of the main deposition methods currently used: sequential deposition and the anti-solvent method. We study the reaction of a metal halide (lead iodide) with an organic compound (methylammonium iodide) using confocal laser scanning fluorescence microscopy and scanning electron microscopy. The lead iodide crystallizes before the intercalation of methylammonium iodide commences, producing the methylammonium lead iodide perovskite. We find that the formation of perovskite via such a sequential deposition is much accelerated by light. The influence of light on morphology is reflected in a doubling of solar-cell efficiency. Conversely, using the anti-solvent method to form methyl ammonium lead iodide perovskite in a single step from the same starting materials, we find that the best photovoltaic performance is obtained when films are produced in the dark. The discovery of light-activated crystallization not only identifies a previously unknown source of variability in opto-electronic properties, but also opens up new ways of tuning morphology and structuring perovskites for various applications.