Magnetotactic bacteria (MTB) play an important role in Earth's biogeochemical cycles by transporting minerals in aquatic ecosystems, and have shown promise for controlled transport of microscale objects in flow conditions. However, how MTB traverse complex flow environments is not clear. Here, using microfluidics and high-speed imaging, it is revealed that magnetotaxis enables directed motion of Magnetospirillum magneticum over long distances in flow velocities ranging from 2 to 1260 µm s , corresponding to shear rates ranging from 0.2 to 142 s -a range relevant to both aquatic environments and biomedical applications. The ability of MTB to overcome a current is influenced by the flow, the magnetic field, and their relative orientation. MTB can overcome 2.3-fold higher flow velocities when directed to swim perpendicular to the flow as compared to upstream, as the latter orientation induces higher drag. The results indicate a threshold drag of 9.5 pN, corresponding to a flow velocity of 550 µm s , where magnetotaxis enables MTB to overcome counterdirectional flow. These findings bring new insights into the interactions of MTB with complex flow environments relevant to aquatic ecosystems, while suggesting opportunities for in vivo applications of MTB in microbiorobotics and targeted drug delivery.