A crowd of pedestrians is a complex system that exhibits a rich variety of self-organized collective behaviours. For instance, when two flows of people are walking in opposite directions in a crowded street, pedestrians spontaneously share the available space by forming lanes of uniform walking directions. This “pedestrian highway” is a typical example of self-organized functional pattern, as it increases the traffic efficiency with no need of external control. In this work, we have conducted a series of laboratory experiments to determine the behavioral mechanisms underlying this pattern. In contrast to previous theoretical predictions, we found that the traffic organization actually alternates in time between well-organized and disorganized states. Our results demonstrate that this unstable dynamics is due to interactions between people walking faster and slower than the average speed of the crowd. While the traffic efficiency is maximized when everybody walks at the same speed, crowd heterogeneity reduces the collective benefits provided by the traffic segregation. This work is a step ahead in understanding the mechanisms of crowd self-organization, and opens the way for the elaboration of management strategies bound to promote smart collective behaviors.