As a superconducting thin film becomes disordered and subject to an increasing magnetic field, a point is reached when it undergoes a transition from a superconducting to an insulating state. We use the Bogoliubov-De-Gennes equations and a novel Monte-Carlo approach to study this transition numerically, starting from a microscopic hamiltonian. The key effect of disorder is to create 'islands' of strong superconductivity, coupled by regions that are only weakly superconducting. In the case of weak disorder, an increasing magnetic field eventually destroys the superconducting state throughout the material, leading to an insulator. On the other hand, when disorder is strong, superconductivity persists in the islands, and the effect of a magnetic field is to suppress the coupling between them, resulting in strong superconducting phase fluctuations, again leading to an insulating state. These findings may be relevant to the high-temperature superconductors, where intrinsic disorder may play a role.