Shinto is the religion of the peoples who invaded Japan in the first millennium BCE. Bringing a sophisticated iron age culture from the mainland, they overcame the Ainu peoples. The religion which came with them was related to the traditional religion of China. Shinto means the 'Way of the Gods' and identified the presence of gods, or spirits, in nature (a comparison can be made with the Genius of the Place in Roman religion). The 'to' in 'Shinto' is related to the 'tao' in Chinese Taoism. This ancestry made it easy for Shinto to become inter-twined with Buddhism and Shinto was often the substratum of Japanese Buddhism, important in the making of Zen Buddhist gardens.
The spirits which exist in nature (kami) included the sun goddess Amaterasu (see, for comparison, the role of Atum in Egyptian religion). Sexual congress between the earliest gods produced the islands of Japan with its mountains, trees, winds, streams and Amaterasu. The Japanese people were descended from kami and the emperor from Amaterasu. All came from nature. Shinto emphasised purity, obtained by ritual washing. Birth and death were regarded as polluting and death could make it necessary to construct a new dwelling.