Shrines are Shinto, Temples are Buddhist
Shrines and temples are both religious establishments. However, the religions from which they originate are different - shrines are from Shintoism, while temples are from Buddhism.
Shinto is a specific ethnic religion that has taken root in Japan since ancient times. Shinto has an exceedingly large number of deities because of the belief that all things are inhabited by gods, thus the Shinto term "eight million gods."
Buddhism originated in India around 450 BCE and was introduced to Japan around the 6th century. In Buddhism, salvation can be achieved by conducting ascetic practices and renouncing anything that prevents enlightenment. Worldwide, it has the third largest number of believers after Christianity and Islam.
Visiting and Worshipping at Shrines and Temples
The way people visit or worship at shrines and temples differ, but they have commonalities. One commonality is when passing through a torii (Shinto gate) or sanmon (Buddhist gate) that marks the boundary between the earthly world and the shrine or temple grounds, the visitor should bow. If there is a chozuya or place for the ritual washing of the hands and mouth, the visitor should purify their hands and mouth with water.
At the chozuya, rinse one hand first with water drawn using a ladle. Then hold the ladle with the cleansed hand and rinse the other hand. While still holding the ladle, rinse the mouth. Finally, hold the ladle upright and rinse the handle. The whole process should be completed only using a full ladle of water drawn at the beginning.
At a shrine, first offer money at the haiden or hall of worship and ring the bell if there is one. Next, deeply bow twice, and loudly clap your hands twice. Say your request silently while pressing your hands together as if in prayer, bow again deeply, then leave.
At a temple, there may be large incense burners called jokoro. If there is one, purify your body by drawing the smoke to you using your hands. Proceed to the main hall, offer money, press your hands together as if in prayer, and bow. While keeping your hands pressed together, say your requests and words of thanksgiving silently. Then bow again and leave. These are the basics, but both Shintoism and Buddhism have various sects, and the rituals may slightly differ depending on the sect.
Distinguishing Between a Shrine and a Temple
A shrine has a torii gate.
Most shrines have a torii gate at the start of a path that leads to the main shrine. Within the shrine grounds, Shinto priests and shrine maidens serve the gods. Shrine names end in “jingu” or “miya” which connote a connection to the Imperial Family; while some shrines that attract many believers have “taisha” in their names, or “sha” which means small, but nevertheless, all are considered shrines.
A temple has a bell.
Instead of a torii gate, a temple has a sanmon or “mountain gate.” In the olden days, many temples were located in the mountains, so the gate that served as the entrance to the temple came to be known as the "mountain gate.”
Inside the sanmon are the temple grounds where monks conduct ascetic practices. Many temples have a temple bell within the temple grounds which is used to indicate the time and signal the beginning of rituals.