The formation of the Earth as a planet was a large stochastic process in which the rapid assembly of asteroidal-to-Mars-sized bodies was followed by a more extended period of growth through collisions of these objects, facilitated by the gravitational perturbations associated with Jupiter. The Earth's inventory of water and organic molecules may have come from diverse sources, not more than 10% roughly from comets, the rest from asteroidal precursors to chondritic bodies and possibly objects near Earth's orbit for which no representative class of meteorites exists today in laboratory collections. The final assembly of the Earth included a catastrophic impact with a Mars-sized body, ejecting mantle and crustal material to form the Moon, and also devolatilizing part of the Earth. A magma ocean and steam atmosphere (possibly with silica vapour) existed briefly in this period, but terrestrial surface waters were below the critical point within 100 million years after Earth's formation, and liquid water existed continuously on the surface within a few hundred million years. Organic material delivered by comets and asteroids would have survived, in part, this violent early period, but frequent impacts of remaining debris probably prevented the continuous habitability of the Earth for one to several hundred million years. Planetary analogues to or records of this early time when life began include Io (heat flow), Titan (organic chemistry) and Venus (remnant early granites).