Tenjin is the deified spirit of Sugawara no Michizane, a real historical person, a scholar, poet and high official who lived in the ninth and early tenth centuries, and his case is the classic Japanese instance of a wronged and vengeful spirit pacified and raised into a beneficent god. Michizane was one of the most brilliant men of his age, a master of Chinese learning and poetry who rose to high office at the imperial court; but he fell victim to the intrigues of the rival Fujiwara family, was falsely accused, stripped of his rank, and sent into effective exile far from the capital at Dazaifu in Kyushu, where he died in bitterness and disgrace.
Michizane's cult was formally established at Kitano Tenmangu in Kyoto, founded in 947, some forty years after his death in exile in 903. In the intervening decades a chain of misfortunes, including the deaths of several courtiers implicated in his fall and a lightning strike on the imperial palace in 930 that killed and injured members of the court, were read as signs of his vengeful spirit, and the court responded in the traditional manner for pacifying an angry ghost, granting him a grand posthumous title and a shrine, which transformed a wronged official into Tenjin, god of thunder and, in time, of scholarship; Kitano Tenmangu remains the head shrine of some twelve thousand Tenjin and Tenmangu shrines across Japan.