The Middle Ages. It's an old part of common law.
I highly doubt that many US states have church sanctuary laws. However by custom, authorities don't like to enter churches to make arrests