The planet HD 209458 b is one of the most well studied hot-Jupiter exoplanets . The upper atmosphere of this planet has been observed through ultraviolet/optical transit observations with H i observation of the exosphere revealing atmospheric escape . At lower altitudes just below the thermosphere , detailed observations of the Na i absorption line has revealed an atmospheric thermal inversion . This thermal structure is rising toward high temperatures at high altitudes , as predicted by models of the thermosphere , and could reach \sim 10 000 K at the exobase level . Here , we report new near ultraviolet Hubble Space Telescope / Space Telescope Imaging Spectrograpgh ( HST/STIS ) observations of atmospheric absorptions during the planetary transit of HD 209458 b . We report absorption in atomic magnesium ( Mg i ) , while no signal has been detected in the lines of singly ionized magnesium ( Mg ii ) . We measure the Mg i atmospheric absorption to be 6.2 \pm 2.9 % in the velocity range from -62 to -19 km/s . The detection of atomic magnesium in the planetary upper atmosphere at a distance of several planetary radii gives a first view into the transition region between the thermosphere and the exobase , where atmospheric escape takes place . We estimate the electronic densities needed to compensate for the photo-ionization by dielectronic recombination of Mg+ to be in the range of 10 ^ { 8 } –- 10 ^ { 9 } cm ^ { -3 } . Our finding is in excellent agreement with model predictions at altitudes of several planetary radii . We observe Mg i atoms escaping the planet , with a maximum radial velocity ( in the stellar rest frame ) of -60 km/s . Because magnesium is much heavier than hydrogen , the escape of this species confirms previous studies that the planet ’ s atmosphere is undergoing hydrodynamic escape . We compare our observations to a numerical model that takes the stellar radiation pressure on the Mg i atoms into account . We find that the Mg i atoms must be present at up to \sim 7.5  planetari radii altitude and estimate an Mg i escape rate of \sim 3 \times 10 ^ { 7 }  g s ^ { -1 } . Compared to previous evaluations of the escape rate of H i atoms , this evaluation is compatible with a magnesium abundance roughly solar . A hint of absorption , detected at low level of significance , during the post-transit observations , could be interpreted as a Mg i cometary-like tail . If true , the estimate of the absorption by Mg i would be increased to a higher value of about 8.8 \pm 2.1 % .