The accretion process, by which 1 km planetesimals grow into 1,000 km sized bodies, is well understood now. This process develops inside any disk where the number density of planetesimals is sufficiently high, and proceeds in a runaway manner. Growth later slows and continues as oligarchic accretion. The end result is formation of planetary embryos of varying sizes, which depend on the distance from the star. Various simulations have demonstrated that the merger of embryos in the inner part of the protoplanetary disk leads to the formation of a few Earth-sized bodies. Thus the origin of terrestrial planets is now considered to be an almost solved problem.