I was typing this as an answer to Jim's comment, but I might as well make it a post and be done with it. I don't really have much time to spend hours reading on religion in ancient Japan, interesting as it is. So I'll just start typing and see what comes out of it.
The gist of the issue is that Shinto was usual local animism, and the introduction of Buddhism with their holy ascetic monks and sutras and shit basically killed Shinto and replaced it for all purposes. Shinto animism was just your typical local spirit worship, and some clan god worship. Everybody had their dear gods/spirits who they prayed to or appeased, and that was it. The priests or wizards usually came from the same family of retainers of the local lord.
Then in the 6th century the imperial family's relatives in the Korean peninsula bring Buddhism, saying it's The Truth, and it's awesome. The Yamato court agrees, and Buddhism starts to spread like wildfire, together with their huge fancy temples, weird sutras in classical chinese, and ascetic monks.
Apparently the court start building temples next to any Shinto shrine of significance. I imagine it was a power coup to make the local clans understand who was boss now. Sure, you can pray to your clan god; but see this amazing temple just next to it! So much bigger and colorful. Eventually people got the message.
Big temple is big
And Buddhism is of course more attractive. Besides the fancy buildings and exotic songs; it has tales of heaven and hell, on how to behave, and the Buddhism trademark on how to stop suffering. People like that, and soon enough it was all temples and no shrines. Praying to the gods never worked very well when you think about it.
Buddhist temples were large corporations, extensive temples with hundreds of monks, supported by tax-free land grants from the court. Buddhist monks have a rather easy life, but it isn't easy to become a monk in the first place. Shave your head; no meat, no beer, no sex; hard schedule; regular visits to frozen rivers and high mountains to enrich your spirit. But hey, free food! And holiness. The temples obviously didn't reproduce themselves, but there was no shortage of monks.
Animism wasn't totally eliminated of course. Superstition about appeasing the local spirits never dies out; and some clans did their Buddhist thing, then make some offerings to the clan god anyway. In the end religion as an activity is a single thing for most people, so Shinto merged with Buddhism; mostly by building an altar inside the wider Buddhist temple. Some older, bigger shrines associated with big clans or the imperial family, such as what today is Izumo Taisha, managed to survive, but they were very influenced by the nearby Buddhist temples, from which they copied art style and ritual.
Apparently the theoretical rationale that people came up with was that spirits had the same problems as people, so spirits also needed to visit temples to get their desire out of them so they could earn nirvana. Then some spirits became Boddhisatvas and whatever. I'm no expert in Buddhism and it's always struck me as a huge pile of nonsense; but it's clear that the Japanese saw no contradiction in the two, and were quite happy to merge them, and Buddhism always had the upper hand, both in superior theology and superior management.
Buddhist temples being a superior business enterprise, especially in their management of human resources and public relations, started to get big, and numerous. They got land, they got people, and they got a hand in the court. Eventually the Heian court collapses in the 12th century, but by then the temples had armed themselves and were pretty good at defending their holdings, and could even fight outside as mercenaries.
Monks went to China to study the scriptures, came back with new theories which were holier than anything before. They started preaching and getting the peasants worked up on stories of Amida, an awesome boddhi-something that takes you to heaven if you say her name all the time. Then this Nichiren guy comes up and says there's one single sutra where all the good stuff is in. But you don't even have to read it; it's in classical chinese after all. So just say the name of the sutra all the time and you're set, straight to heaven. And then there's all this Zen stuff.
Some centuries of civil war and tenuous military governments pass, and eventually the new samurai lords got pissed with the temples not paying taxes and sending warrior monks everywhere; so they beat the shit out of them. However this is the 16th century and the Iberians are selling muskets only to Christian converts. Destroying the temples may give the Christians a chance to expand, and we don't want that. But you still want to take the temple lands, and you really really want to take their pikes.
So the Tokugawas in 1600 had this stroke of genius. Really, the sheer administrative brilliance that the early Edo period statesman came up with is a marvel of innovative government. What they did with religion is:
1. Forbid the construction of new temples or foundation of new sects
2. Force every single person in the country to register with their local temple.
3. Make the temple certify that they are not Christian.
And that's it. They call it the Danka System, Danka being the name of the households that financially support a temple. Now every single household was forced to become a Danka and pay for their temple. That way the government could take the temple's lands without having it collapse. And they also got a free of charge nationwide household registry, and the temples were financially incentivized to check for any traces of Christianity.
On the other hand, the temples now had a legal monopoly on the household registry system. Which means they could force the people to do anything they wanted, lest they branded you a Christian or some other strange sect that were forbidden later. Not having your registry in order was basically a death sentence; so the temples had right of life or death over the local populace.
You can imagine what happened. The temples started forcing everybody to give money on demand, to do a whole set of annual rites on the temple, to provide labor when needed, and whatever the local monks wanted you to do. Holiness competition was outlawed, so the temples became just another state bureaucracy, albeit a very powerful, and hence rapacious one.
People tend to like their church more than their bureaucrats. So the faith of the populace in Buddhism plummeted pretty fast. Eventually the monks stopped pretending they actually understood the sutras, and Buddhism became just a pretty damn expensive funeral service. Which it still is, by the way.
Now, it's one thing for the government to tame religion and make it a state bureaucracy. But that means there's a religious vacuum there waiting to be filled. People actually want to believe in something; and if the damn temples were beyond contempt, well surely there must be something out there worthy of worship.
As I touched upon in my Monarchy post, the intelligentsia of Edo period Japan were the Kokugaku guys; the national studies, which was a combination of decoding the old classics of the Imperial era, and some readings on Chinese Neoconfucianism. As it happened, the Chinese Confucians had been anti-Buddhist for a long time, and they had their own Confucian ethics to propose in place of the weird asceticism of Buddhism. This only fit with what the Samurai wanted to hear. And luckily the Japanese scholars had an even better fit for a good religion that the Confucians themselves. Confucianism in its origin was a nostalgic cult which worshiped the Zhou court and its rituals. But the Zhou court was destroyed, and the Zhou kings disappeared. So Confucians for 2000 years had to carry this weird cognitive dissonance in which they worshiped a past which was summarily murdered, as would all the successive dynasties that were built in its place.
But Japan actually had the old imperial court around; the imperial line survived there in Kyoto. And even the ancient religion was still around, lingering in a handful of obscure shrines in the provinces, and in the folk religion of the peasants. If we only washed away the corruptive influence of Buddhism in the shrines, and try to reconstruct the ancient spirit worship as is depicted in the ancient texts; then we'd have the perfect ancestral religion of the Japanese nation. They found some reference to Shinto opposed to Buddhism in the ancient texts, so voila, Shinto it is. The true religion of Japan.
As we know the National Studies guys won the culture war, and any Samurai scholar worth his salt was a fanatic believer on the divinity of the Unbroken Imperial Line, the True Religion of Japan, and the necessity of overthrowing the evil Shogun. And overthrown he was in 1868, in the Meiji Restoration. Which was a bottom-up revolution if I ever saw one, but like the fascists that would storm Europe 50 years later, leftist revolutions go down easier if you dress them up as rightist restorations. As always the Japanese were decades before everyone else.
After the Edo government fell, the first thing the Meiji did was turn against the hated Buddhist temples. A law mandated the separation of Shinto and Buddhism was passed, upon which all shrines were to expel any monks, Buddhist texts, figures or utensils found inside them, and they were to be put under the administration of the government. Soon some overzealous Samurai started going against the temples, and masses across the country started burning temples, destroying figures, and expelling monks en masse. And I guess killing some monks and raping some nuns, but the sources aren't clear.
The extent of the Buddhism purge varied among regions, the worst case being in Satsuma, the core of the Meiji revolution. 1600 temples were vacated, the monks drafted as soldiers and their wealth given to the army. And that was that. It does sound quite similar to the closing of the monasteries by Henry VIII of England, and I wonder if any of the Meiji guys had heard of it.
And so the government established a Shinto Ministry with high hopes for the establishment of a national religion based on the old imperial rites. But it only lasted 6 months. Basically the Shinto theologians they hired to preach around the country couldn't agree on a single tenet of faith, and there weren't that many of them to begin with. The Buddhist temples had started to complain about their unfair treatment; and as hated as they were in some places, it wasn't all that universal, and the temples did run schools across the country. If anyone had the expertise to teach a religion to all the peasants, it was them. So the government surrendered, and came up with a new Teaching Ministry that included the Buddhists, while the imperial rituals were transferred to the imperial household bureau.
But that Teaching Ministry didn't last much longer either. After 5 years it was out, its work divided between the new Education Ministry, and the court ritual parts transferred to a new Shrines and Temples bureau. For all their hopes of a new national religion; the fact is that, first, the ban on Christianity had to be lifted, else whitey and his gunships are gonna get very angry. Speaking of whitey, they tell us they have this thing called compulsory universal education, where they get all the kids in the country and lock them in a room for hours a day to teach them stuff. Might as well do the religion thing there, instead of the shrines and temples.
The Shrines and Temples Bureau did their thing, which was make sure the Shinto places were free of any Buddhist influence, and that the Buddhist temples didn't do anything strange. Buddhist monks were allowed to take wives, eat meat, and basically pay no attention to their monastic vows. Many had been secretly taking wives and having children since their Household Registry days during the Shogunate, but they weren't supposed to. The Meiji government told them it was cool, and they overwhelmingly chose to. Industrialization and the new army meant that there weren't that many aspirants to the monastic life, and the Buddhist temples basically evolved into hereditary fiefs of the chief monk. To this day, the chief monks of Japanese temples inherit their job from their father, even though the temple grounds aren't their personal property; the temple is a corporation.
Buddhist temples having lost their government privilege couldn't coerce the peasants into paying regularly or attending 5 rituals a year; but inertia is a funny thing, and to this day the Buddhist are in charge of most funerals in the country, for which they charge some serious money. You do want your daddy to go to heaven with good standing, right? It is slowly breaking down though, as even the last remnants of peasant superstition are starting to wear off.
So what about the Shinto shrines? As I've been saying the whole thing was totally made up by the Meiji guys. Shinto had no theology, and not that many shrines to begin with. There was a continuum of pure Buddhist temples to Buddhist-animist temples to formerly-important Shrines which had been mostly colonized by Buddhism over the centuries. The Meiji ordered a cleanup, and they built a lot of new ones, and made the whole thing into a neat state bureaucracy, with a hierarchy of priests and grades depending on passing a state exam.on ritual acumen. Yeah, they have exams, kinda like Karate but praying.
However, while Shinto was cleaned up and made into a fairly neat system of courtly rituals, it was never made into a state religion worth its name. The original idea was to have a God Ministry which was in charge of court rituals, the nation's shrines and public education. First the rituals were transferred to another agency, and then education and religion were separated for good. One big reason was that the Western powers weren't very cool with a non-Christian state religion, and they had the big guns. But the main reason was that the religion just wasn't there. There was a cool mythology of Sun Goddesses and their progeny that end up in the Emperor himself; but you can teach that in a couple of history classes. There was little else to it; and while the bureaucracy came up with new rituals to entice the people to visit the shrines, it never amounted to much. The Aristocracy were forced by law to change their funerals to Shinto style, but the commoners preferred to stick to what they knew. Mostly for inertia; but Buddhism has a fairly detailed account on heaven and hell, and you don't wanna get that wrong.
After WW2, the McArthur administration scrapped the whole Shinto bureaucracy, and the temples became a private corporation, which runs the exams and the rest of the paperwork. The priests now are not bureaucrats, and have become an hereditary position. The shrines remain cleaned up and separate from Buddhism; and privatization has made the shrines more efficient. While Buddhism is declining, complacent in the easy money that the funeral business provides, Shinto shrines have monopolized the fun stuff. Shinto weddings are a thing among conservative people with money (most people get a white fake priest in a fake white church), and religious rituals with children (to pray for health at age 3 and things like that) are exclusively done in Shinto shrines these days. Summer festivals and their wild processions have come to be associated with Shinto, when it wasn't like that before.
Jim says that the civility, tenacity and hard work of the Japanese comes from Shintoism, but that's transparent bullshit. The way more tenacious and hardworking Samurai (I mean the original warriors) were pious Buddhists, and Shinto was, as I said, a fairly empty theological contraption. In the end it was only a thin veneer, hardly more than a class on patriotic education. Saying Japan works because of Shinto would be like saying Germans were good soldiers because of Nazism, which doesn't sound fair.
Of course patriotism does work to an extent, but you hardly need a full religion to have patriotism. And it doesn't explain much; Japan and Germany today are still very functional and pleasant societies; but their people could hardly be called patriotic. The modern Japanese are a fairly decadent and hedonistic bunch; as are the Germans.
What is it then? I think that the fascist ideologies of roughly 1870-1945 are a consequence and not a cause. Japan, Germany and crucially Italy too developed their rather rabid strand of nationalism because they weren't real nations to begin with. Before their political unification, they were but areas of cultural unity, but politically independent, or at least highly autonomous principalities.The feudal han of Edo period Japan were of course subject to the Shogun, but they were virtually independent in most legislation, and they kept their own schools and armies; which was the Shogunate's undoing in the end.
The argument has been done that it was this very disunity that produced the literate and civil society of today (southern Italy being an exception; it was a centralized monarchy in its own). Ruling a country is hard, and ruling a large country is harder still. The biggest problem for the ruler of a large country is to prevent rebellion; which is of course harder the larger and more populous the country is. The easiest way to prevent rebellions is by tampering with the ability of people to assemble and organize themselves, and by impeding their access to information.
Smaller principalities don't have that problem; the concentric loyalty networks of patronage which are the basis of any power structure are short enough that a ruler can be secure in his place by sheer force of custom. A ruler is just a few degrees of separation from any commoner, who is tied to him by actually understandable chains of loyalty. It's Dunbar-compatible (my coining). Such a ruler has no need to tamper with the local flows of information, or from stopping people from assembling or becoming literate. Edo period Japan was a very highly literate society, and had fairly advanced economic networks (the rice futures of Osaka are famous). That didn't make it a restless or revolutionary place; everybody had Dunbar-compatible personal loyalties to the system, and they stayed in place until the outside shock of Western intervention 250 years later.
The breaking up of this system meant that a rather more abstract nation-state had to be built to replace the old feudalism; and it had to be quick. Japanese, Germans and Italians compensated their lack of actual national ties by going full retard on the national essence, the Gods and the Blood and whatever holy-sounding crap they could come up with. It didn't work; most people never cared much for the overblown rhetoric. But people went along and fought valiantly because they were conditioned by their long culture of loyalty to their immediate superiors (not so much in Italy I guess, but I'm no expert in Italian city state history. I guess the periods of French, Spanish and Austrian rule didn't help). And that's why Germans and Japanese were great soldiers, while Chinese and Russians died in millions when their centralized bureaucracy collapsed, or almost did.
The failure of State Shinto (as it's called by modern historians) also shows that you can't make up a state religion just like that. Of course in my defense I could say that the Meiji government didn't try very hard (giving up and shutting down the Ministry in 6 months? Come on). And Japan was trying to come up with a religion in a situation of effective religious vacuum. While my proposal is about replacing a positively harmful religion which afflicts the West today. In the end the Japanese didn't need a religion, and the vacuum continues to this day. But Westerners clearly can't function without theology, so if we want to do away with Social Justice, we're gonna need to replace it with something.
Something good though. Certainly not Shinto.