While the foundation of American democracy makes a point of separating church and state, the history of money is inextricably tied to religion. When the world economy was based on bartering, cows didn’t require a bovine bank, but as governments and wealthier citizens evolved and minted currency, a more structured solution was called for.

Before buildings formally existed for the sole purpose of banking, gold and coins were stored and sometimes even minted out of temples. People could go to a temple to validate that their coins were legitimate, and people with enough wealth to consider worth storing could make deposits, exchanges, and loans there. In fact, the word temple comes from the phrase meaning “treasure houses” and the words money and mint come from the ancient Roman goddess Juno Moneta, whose temple served both religious and financial purposes.

There’s historical evidence that temples handled currency in Mesopotamia, Egypt, Greece, and, of course, Rome. Even the legendary Acropolis, a temple of Athena still present today, stored money.

Why? Convenience, for starters. Every major city already had one in a central location. Temples were also the safest option because there was always a trustworthy person there to keep watch. Priests were also literate and able to maintain and store records. As an added perk, thieves were less likely to steal from a temple for fear of divine punishment.

Religion’s role in the history of banking doesn’t stop at its physical structures. Major religious texts including the Bible, Torah, and Quran, all lay out their own guidelines on charging interest.

As merchants, and therefore countries, became wealthier, capitalism developed to support the money and merchandise changing hands. Warfare was also becoming more sophisticated and more expensive, and the temple system was no longer cutting it. The richest cities in Europe were all in Italy, so good old Ancient Rome stepped up to organize the model of a public bank with a central administration. From there, it was just a few centuries’ leap to ATMs.