Shrine belongs to Shinto, Temple belongs to Buddhism
These two religious buildings are sometimes confusing to tourists visiting Japan. In short, the difference is what is the building enshrines. A Japanese temple enshrines various incarnations of Buddha. Also a Japanese shrine enshrines various Shinto Deities.
Buddhism has several denominations, Shinto has only one denomination
Shinto was established in Japan in ancient times by ancestors. Conversely Buddhism was established in India also in ancient times and imported to Japan about 1,500 years ago. Buddhism has several major denominations around Asia, also have several miner denominations in Japan. Japanese temples are belonging one of the denominations. However there is no such conflicts among denominations. Japanese do not conscious of the denominations usually we visit temples.
There was an era Shinto and Buddhism was mixed in Japan for long time
One of Japan's cultural feature is "adaptation", after the import of Buddhism, it became very close to Shinto and those two religions were mixed and there was an era even incarnations of Buddha and Shinto Deities seemed as the same incarnations that has two character in each religions. Therefore, many temples still has a shrine in the same site together, they are holdover from the past.
Worship Manners are different
In a shrine, visitors clap their hands when they pray, however, in a temple, there is no manners to clap hands to pray. For details, please see the article Worship Manners in Japanese Shrine.