As described in Leviticus 16:1-27, part of a Hebrew ritual on the Day of Atonement involved the presentation of two male goats at the altar of the tabernacle.
After lots were cast, one goat was sacrificed to the Lord; the other, the scapegoat, was set aside for Azazel, an evil spirit of the wilderness.
The high priest transferred the sins of the people onto this goat and sent it away into the desert.