Conventional two-dimensional electron gases are realized by engineering the interfaces between semiconducting compounds. In 2004, Ohtomo and Hwang discovered that an electron gas can be also realized at the interface between large gap insulators made of transition metal oxides [1]. This finding has generated considerable efforts to clarify the underlying microscopic mechanism. Of particular interest is the LaAlO3/SrTiO3 system, because it features especially striking properties. High carrier mobility [1], electric field tuneable superconductivity [2] and magnetic effects [3], have been found. Here we show that an orbital reconstruction is underlying the generation of the electron gas at the LaAlO3/SrTiO3 n-type interface. Our results are based on extensive investigations of the electronic properties and of the orbital structure of the interface using X-ray Absorption Spectroscopy. In particular we find that the degeneracy of the Ti 3d states is fully removed, and that the Ti 3dxy levels become the first available states for conducting electrons.