As a custom, the ema goes back to the Nara Period (710-794). It spread from Shinto shrines to Buddhist temples and was quite popular during the Edo Period (1603-1867). But even back then ...