Albatrosses do something that no other birds are able to do: fly thousands of kilometres at no mechanical cost. This is possible because they use dynamic soaring, a flight mode that enables them to gain the energy required for flying from wind. Until now, the physical mechanisms of the energy gain in terms of the energy transfer from the wind to the bird were mostly unknown. Here we show that the energy gain is achieved by a dynamic flight manoeuvre consisting of a continually repeated up-down curve with optimal adjustment to the wind. We determined the energy obtained from the wind by analysing the measured trajectories of free flying birds using a new GPS-signal tracking method yielding a high precision. Our results reveal an evolutionary adaptation to an extreme environment, and may support recent biologically inspired research on robotic aircraft that might utilize albatrosses' flight technique for engineless propulsion.