Believe it or not, Shinto is a modern invention. Well, modern as in 19th century. Before that "Shinto" as we know it today did not exist. There was kami worship and that dates back to the earliest history of Japan, but Shinto was sort of a necessary experiment. For over one thousand years Buddhism had reigned supreme--since it's introduction in the late 6th century. Before that the Imperial Court enjoyed the benefit of being ikigami, or living gods. Once Buddhism took hold of the country the Imperial families and their courts took a back seat to the Buddha and the different schools of thought that emerged in Japan. After the last Tokugawa shogun turned over his power back to the Imperial family in 1867, the emerging state took advantage of this opportunity to reinstate the royal family as living gods.

Osei fuko, the restoration of imperial rule, was the motivation for creating this new religion. There was a desire to move away from jaho, or heretical law, in this case Buddhism, and a strong shift towards the doctrine of the imperial nation once again. What's interesting is that up until that point Shinto rituals had been performed by both Shinto priest and Buddhist monks. The two beliefs were strongly intertwined. But now with the Imperial family back on top there was a need to nip Buddhism's power over the country in the butt. The Great Promulgation Campaign to properly identify Shinto as the state religion started in 1870 and continued until 1884.

Let me back up and clarify that Shinto was not a unified or specific set of beliefs that could be identified before that point. There was a need to define what Shinto was in order for it to become the state religion, and that was what spurred the persecution of Buddhism.