Balaam was a pagan magician hired by Balak, king of Moab, to curse Israel according to Book of Numbers chapter 22 in the Bible. Balaam refused to curse Israel for Balak, because God told him that they were blessed and not cursed. At a later time after the abandonment of the cursing, Balaam was riding his donkey when the donkey saw an angel waiting ahead to kill Balaam and tried to stop. Balaam was cruel to the beast not knowing why it was stopping, until it opened up its mouth and talked to him and let him know he was about to die. Balaam then understood and did not proceed.
Balaam's full story is recounted from Numbers 22 to 24.