Deuteronomy 17:2-8
2 “If there is found among you, within any of your towns that the Lord your God is giving you, a man or woman who does what is evil in the sight of the Lord your God, in transgressing his covenant, 3 and has gone and served other gods and worshiped them, or the sun or the moon or any of the host of heaven, which I have forbidden, 4 and it is told you and you hear of it, then you shall inquire diligently, and if it is true and certain that such an abomination has been done in Israel, 5 then you shall bring out to your gates that man or woman who has done this evil thing, and you shall stone that man or woman to death with stones. 6 On the evidence of two witnesses or of three witnesses the one who is to die shall be put to death; a person shall not be put to death on the evidence of one witness. 7 The hand of the witnesses shall be first against him to put him to death, and afterward the hand of all the people. So you shall purge the evil from your midst.

From Matthew Henry’s Commentary:
- Be it (worshipping of false gods) ever so indusriously concealed, he(God) sees it, and be it ever so ingeniously palliated, he (God) hates it: it is a sin in itself exceedingly heinous, and the highest affront that can be offered to Almighty God.
- That it is a transgression of the covenant.
- It was on this condition that God took them to be his peculiar people, that the should serve and worship him only as their God, so that if they gave to any other the honor which was due to him alone that covenant was void, and all the benefit of it forfeited.
- Other sins were transgressions of the command, but this was a transgression of the covenant.
- It was spiritual adultery, which breaks the marriage bond.