The original meaning of "religion" in Arabic ("Din") is law. What you call "religious error" is tantamount to "illegal behaviour" to others.
Seems unrelated to Hindi (via Sanskrit) दिन 'din' meaning 'day' though. (Not that I expected it because 'day' and 'religious' are similar in meaning, just curious because there is overlap, and borrowed terms (well, with Persian, but those in turn often derived or cognate with Arabic, at least in my idly curious Wiktionaring experience anyway).)