Let X be an algebraic variety and let S be a tropical variety associated to X. We study the tropicalization map from the moduli space of stable maps into X to the moduli space of tropical curves in S. We prove that it is a continuous map and that its image is compact and polyhedral. Loosely speaking, when we deform algebraic curves in X, the associated tropical curves in S deform continuously; moreover, the locus of realizable tropical curves inside the space of all tropical curves is compact and polyhedral. Our main tools are Berkovich spaces, formal models, balancing conditions, vanishing cycles and quantifier elimination for rigid subanalytic sets.