We study the formation of stellar haloes in three Milky Way-mass galaxies using cosmological smoothed particle hydrodynamics simulations, focusing on the subset of halo stars that form in situ, as opposed to those accreted from satellites. In situ stars in our simulations dominate the stellar halo out to 20 kpc and account for 30-40 per cent of its total mass. We separate in situ halo stars into three straightforward, physically distinct categories according to their origin: stars scattered from the disc of the main galaxy (heated disc), stars formed from gas smoothly accreted on to the halo (smooth gas) and stars formed in streams of gas stripped from infalling satellites (stripped gas). We find that most belong to the stripped gas category. Those originating in smooth gas outside the disc tend to form at the same time and place as the stripped-gas population, suggesting that their formation is associated with the same gas-rich accretion events. The scattered disc star contribution is negligible overall but significant in the Solar neighbourhood, where ~90 per cent of stars on eccentric orbits once belonged to the disc. However, the distinction between halo and thick disc in this region is highly ambiguous. The chemical and kinematic properties of the different components are very similar at the present day, but the global properties of the in situ halo differ substantially between the three galaxies in our study. In our simulations, the hierarchical buildup of structure is the driving force behind not only the accreted stellar halo, but also those halo stars formed in situ.