Mergers and the spin of the dark matter halo are factors traditionally believed to determine the morphology of galaxies within a ΛCDM cosmology. We study this hypothesis by considering approximately 18,000 central galaxies at z = 0 with stellar masses M * = 10 9 -10 12 M selected from the Illustris cosmological hydrodynamic simulation. The fraction of accreted stars -which measures the importance of massive, recent and dry mergers -increases steeply with galaxy stellar mass, from less than 5 per cent in dwarfs to 80 per cent in the most massive objects, and the impact of mergers on galaxy morphology increases accordingly. For galaxies with M * 10 11 M , mergers have the expected effect: if gas-poor they promote the formation of spheroidal galaxies, whereas gas-rich mergers favour the formation and survivability of massive discs. This trend, however, breaks at lower masses. For objects with M * 10 11 M , mergers do not seem to play any significant role in determining the morphology, with accreted stellar fractions and mean merger gas fractions that are indistinguishable between spheroidal and disc-dominated galaxies. On the other hand, halo spin correlates with morphology primarily in the least massive objects in the sample (M * 10 10 M ), but only weakly for galaxies above that mass. Our results support a scenario where (1) mergers play a dominant role in shaping the morphology of massive galaxies, (2) halo spin is important for the morphology of dwarfs, and (3) the morphology of medium-sized galaxies -including the Milky Way -shows little dependence on galaxy assembly history or halo spin, at least when these two factors are considered individually.