Context. The atmospheric composition of transiting exoplanets can be characterized during transit by spectroscopy. Detections of several chemical species have previously been reported in the atmosphere of gaseous giant exoplanets. For the transit of an Earth twin, models predict that biogenic oxygen (O 2 ) and ozone (O 3 ) atmospheric gases should be detectable, as well as water vapour (H 2 O), a molecule linked to habitability as we know it on Earth. Aims. The aim is to measure the Earth radius versus wavelength λ -or the atmosphere thickness h(λ) -at the highest spectral resolution available to fully characterize the signature of Earth seen as a transiting exoplanet. Methods. We present observations of the Moon eclipse of December 21, 2010. Seen from the Moon, the Earth eclipses the Sun and opens access to the Earth atmosphere transmission spectrum. We used two different ESO spectrographs (HARPS and UVES) to take penumbra and umbra high-resolution spectra from ≈3100 to 10 400 Å. A change of the quantity of water vapour above the telescope compromised the quality of the UVES data. We corrected for this effect in the data processing. We analyzed the data by three different methods. The first method is based on the analysis of pairs of penumbra spectra. The second makes use of a single penumbra spectrum, and the third of all penumbra and umbra spectra. Results. Profiles h(λ) are obtained with the three methods for both instruments. The first method gives the best result, in agreement with a model. The second method seems to be more sensitive to the Doppler shift of solar spectral lines with respect to the telluric lines. The third method makes use of umbra spectra, which bias the result by increasing the overall negative slope of h(λ). It can be corrected for this a posteriori from results with the first method. The three methods clearly show the spectral signature of the Rayleigh scattering in the Earth atmosphere and the bands of H 2 O, O 2 , and O 3 . Sodium is detected. Assuming no atmospheric perturbations, we show that the E-ELT is theoretically able to detect the O 2 A-band in 8 h of integration for an Earth twin at 10 pc. Conclusions. Biogenic O 2 , O 3 , and water vapour are detected in Earth observed as a transiting planet, and, in principle, would be within reach of the E-ELT for an Earth twin at 10 pc.