Buddhists in around 400 AD wrote Sanskrit with a version of Gupta script that eventually diverged into Siddham script. At first, writing down the Sanskrit was used mostly as a memorization aid, but when Buddhism spread to the much-more literate China, apparently things needed to be written down to be taken seriously. Problem: to recite the mantras properly, you needed to be able to pronounce them properly, and the logographic Chinese script did a really bad job of showing how you should pronounce syllables. Thus the Siddham script moved from being useful to being critical.
A pair of Japanese monks, Kukai and Saicho, traveled to China to study in the early 800s. They brought Siddham texts back to Japan with them and founded highly influential Buddhist schools. About 40 years later, Emperor Tang Wuzong repressed Buddhism in China quite effectively, cutting Japan off from other Buddhist influences. Left undisturbed, Siddham script just happily stayed in Japan long after the Buddhists in India switched over to Devanagari. Siddham is still in use in Japan today, 1200 years later, although it is now called Bonji script.
This makes Siddham relatively old among modern continuously-used scripts, and means that Japan has five scripts that are currently used, not four like you thought.
Links: Wikipedia, Omniglot, Visible Mantra
Pingback: Tibetan — 630 AD, Tibet | Glyph of the Day