Deuteronomy 17:2-7

2 If there is found among you, in one 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, and transgresses his covenant
3 by going to serve other gods and worshiping them—whether the sun or the moon or any of the host of heaven, which I have forbidden—
4 and if it is reported to you or you hear of it, and you make a thorough inquiry, and the charge is proved true that such an abhorrent thing has occurred in Israel,
5 then you shall bring out to your gates that man or that woman who has committed this crime and you shall stone the man or woman to death.
6 On the evidence of two or three witnesses the death sentence shall be executed; a person must not be put to death on the evidence of only one witness.
7 The hands of the witnesses shall be the first raised against the person to execute the death penalty, and afterward the hands of all the people. So you shall purge the evil from your midst.