When animals move, their tracks may be strongly influenced by the motion of air or water, and this may affect the speed, energetics and prospects of the journey. Flying organisms, such as bats, may thus benefit from modifying their flight in response to the wind vector. Yet, practical difficulties have so far limited the understanding of this response for free-ranging bats. We tracked nine straw-coloured fruit bats (Eidolon helvum) that flew 42.5 + 17.5 km (mean + s.d.) to and from their roost near Accra, Ghana. Following detailed atmospheric simulations, we found that bats compensated for wind drift, as predicted under constant winds, and decreased their airspeed in response to tailwind assistance such that their groundspeed remained nearly constant. In addition, bats increased their airspeed with increasing crosswind speed. Overall, bats modulated their airspeed in relation to wind speed at different wind directions in a manner predicted by a two-dimensional optimal movement model. We conclude that sophisticated behavioural mechanisms to minimize the cost of transport under various wind conditions have evolved in bats. The bats' response to the wind is similar to that reported for migratory birds and insects, suggesting convergent evolution of flight behaviours in volant organisms.