Upon cooling, water freezes to ice. This familiar phase transition occurs widely in nature, yet unlike the freezing of simple liquids, it has never been successfully simulated on a computer. The difficulty lies with the fact that hydrogen bonding between individual water molecules yields a disordered three-dimensional hydrogen-bond network whose rugged and complex global potential energy surface permits a large number of possible network configurations. As a result, it is very challenging to reproduce the freezing of 'real' water into a solid with a unique crystalline structure. For systems with a limited number of possible disordered hydrogen-bond network structures, such as confined water, it is relatively easy to locate a pathway from a liquid state to a crystalline structure. For pure and spatially unconfined water, however, molecular dynamics simulations of freezing are severely hampered by the large number of possible network configurations that exist. Here we present a molecular dynamics trajectory that captures the molecular processes involved in the freezing of pure water. We find that ice nucleation occurs once a sufficient number of relatively long-lived hydrogen bonds develop spontaneously at the same location to form a fairly compact initial nucleus. The initial nucleus then slowly changes shape and size until it reaches a stage that allows rapid expansion, resulting in crystallization of the entire system.