Soon after the crowd streamed on to London's Millennium Bridge on the day it opened, the bridge started to sway from side to side: many pedestrians fell spontaneously into step with the bridge's vibrations, inadvertently amplifying them. Here we model this unexpected and now notorious phenomenon--which was not due to the bridge's innovative design as was first thought--by adapting ideas originally developed to describe the collective synchronization of biological oscillators such as neurons and fireflies. Our approach should help engineers to estimate the damping needed to stabilize other exceptionally crowded footbridges against synchronous lateral excitation by pedestrians.