We perform a direct calculation of the gluon momentum fraction of the nucleon, taking into account the mixing with the corresponding quark contribution. We use maximally twisted mass fermion ensembles with N f ¼ 2 þ 1 þ 1 flavors at a pion mass of about 370 MeV and a lattice spacing of a ≈ 0.082 fm and with N f ¼ 2 flavors at the physical pion mass and a lattice spacing of a ≈ 0.093 fm. We employ stout smearing to obtain a statistically significant result for the bare matrix elements. In addition, we perform a lattice perturbative calculation including two levels of stout smearing to carry out the mixing and the renormalization of the quark and gluon operators. We find, after conversion to the MS scheme at a scale of 2 GeV, hxi R g ¼ 0.284ð27Þð17Þð24Þ for pion mass of about 370 MeV and hxi R g ¼ 0.267ð22Þð19Þð24Þ for the physical pion mass. In the reported numbers, the first parenthesis indicates statistical uncertainties. The numbers in the second and third parentheses correspond to systematic uncertainties due to excited states contamination and renormalization, respectively.