We show how wet major mergers can create disc galaxies in a cosmological context, using the Illustris simulation. We select a sample of 38 disc galaxies having experienced a major merger in their history with no subsequent significant minor merger, and study how they transform into discs after the merger. In agreement with what was previously found in controlled simulations of such mergers, we find that their disc is built gradually from young stars formed after the merger in the disc region, while the old stars born before the merger form an ellipsoidal component. Focusing on one fiducial case from our sample, we show how the gas was initially dispersed in the halo region right after the merger, but is then accreted onto a disc to form stars, and builds the disc component. We then select a sample of major mergers creating elliptical galaxies, to show that those cases correspond mainly to dry mergers, where the lack of star formation prevents the formation of a disc in the remnant galaxy. The amount of gas in the remnant galaxy after the merger is therefore essential to determine the final outcome of a major merger.