A magma ocean is a global layer of partially or fully molten rocks. Significant melting of terrestrial planets likely occurs due to heat release during planetary accretion, such as decay heat of short-lived radionuclides, impact energy released by continuous planetesimal accretion, and energetic impacts among planetary-sized bodies (giant impacts). Over a magma ocean, all water, which is released upon impact or degassed from the interior, exists as superheated vapor, forming a water-dominated, steam atmosphere. A magma ocean extending to the surface is expected to interact with the overlying steam atmosphere through material and heat exchange. Impact degassing of water starts when the size of a planetary body becomes larger than Earth’s moon or Mars. The degassed water could build up and form a steam atmosphere on protoplanets growing by planetesimal accretion. The atmosphere has a role in preventing accretion energy supplied by planetesimals from escaping, leading to the formation of a magma ocean. Once a magma ocean forms, part of the steam atmosphere would start to dissolve into the surface magma due to the high solubility of water into silicate melt. Theoretical studies indicated that as long as the magma ocean is present, a negative feedback loop can operate to regulate the amount of the steam atmosphere and to stabilize the surface temperature so that a radiative energy balance is achieved. Protoplanets can also accrete the surrounding H 2 -rich disk gas. Water could be produced by oxidation of H 2 by ferrous iron in the magma. The atmosphere and water on protoplanets could be a mixture of outgassed and disk-gas components. Planets formed by giant impact would experience a global melting on a short timescale. A steam atmosphere could grow by later outgassing from the interior. Its thermal blanketing and greenhouse effects are of great importance in controlling the cooling rate of the magma ocean. Due to the presence of a runaway greenhouse threshold, the crystallization timescale and water budget of terrestrial planets can depend on the orbital distance from the host star. The terrestrial planets in our solar system essentially have no direct record of their earliest history, whereas observations of young terrestrial exoplanets may provide us some insight into what early terrestrial planets and their atmosphere are like. Evolution of protoplanets in the framework of pebble accretion remains unexplored.