Online social networks (OSNs) enable researchers to study the social universe at a previously unattainable scale. The worldwide impact and the necessity to sustain their rapid growth emphasize the importance to unravel the laws governing their evolution. We present a quantitative two-parameter model which reproduces the entire topological evolution of a quasi-isolated OSN with unprecedented precision from the birth of the network. This allows us to precisely gauge the fundamental macroscopic and microscopic mechanisms involved. Our findings suggest that the coupling between the real pre-existing underlying social structure, a viral spreading mechanism, and mass media influence govern the evolution of OSNs. The empirical validation of our model, on a macroscopic scale, reveals that virality is four to five times stronger than mass media influence and, on a microscopic scale, individuals have a higher subscription probability if invited by weaker social contacts, in agreement with the strength of weak ties paradigm.