A long-standing assumption in social behavior is that leadership incurs costs as well as benefits, and this tradeoff can result in diversified social roles in groups. The major cost of leadership in moving animal groups is assumed to be predation, with individuals leading from the front of groups being targeted more often by predators. Nevertheless, empirical evidence for this is limited, and experimental tests are entirely lacking. To avoid confounding effects associated with observational studies, we presented a simulation of virtual prey to real fish predators to directly assess the predation cost of leadership. Prey leading others are at greater risk than those in the middle of groups, confirming that any benefits of leading may be offset by predation costs. Importantly, however, followers confer a net safety benefit to leaders, as prey leading others were less likely to be attacked compared with solitary prey. We also find that the predators preferentially attacked when solitary individuals were more frequent, but this effect was relatively weak compared with the preference for attacking solitary prey during an attack. Using virtual prey, where the appearance and behavior of the prey can be manipulated and controlled exactly, we reveal a hierarchy of risk from solitary to leading to following social strategies. Our results suggest that goal-orientated individuals (i.e., potential leaders) are under selective pressure to maintain group cohesion, favoring effective leadership rather than group fragmentation. Our results have significant implications for understanding the evolution and maintenance of different social roles in groups.