This arch-magician at first tried to escape Israel's power by sorcery. For when he saw Phinehas and the leaders of the hosts of Israel, he flew into the air,  a feat which he accomplished by magic arts, but particularly through the assistance of his wizard sons, Jannes and Jambres. At the sight of Balaam flying high in the air, Phinehas shouted to his army, "Is there any one among us who is able to fly after this villain?" The Danite Zaliah, a past master in the art of sorcery, followed this summons, and flew high into the air. Balaam, however, surpassed him, and took a path in the air on which Zaliah could not follow, and after the former had soared through five different layers of air, he had quite vanished from Zaliah's ken, who knew not what to do. Phinehas, however, came to his aid. By means of a magical invocation he dispelled the clouds that covered Balaam, and then Zaliah forced Balaam to descend to earth and appear before Phinehas.  He began to implore Phinehas to spare his life, promising never again to try to curse Israel, but Phinehas replied: "Art not thou the Aramean Laban who tried to destroy our father Jacob? Then thou didst pass on to Egypt to destroy Jacob's seed, and when they removed from Egypt thou didst incite the wicked Amalek to harass us, and not thou didst attempt to curse Israel. But when thou sawest that thy endeavor to curse them was without avail, since God would not hear thee, thou gavest Balak the despicable advice to deliver up the daughters of his land to prostitution, and thereby to tempt Israel to sin, and wert in part successful, for twenty-four thousand Israelites died in consequence of their sin with the daughters of Moab. In vain therefore dost thou plead that thy life by spared." He then ordered Zaliah to kill Balaam, admonishing him, however, to be sure not to kill him through the holy name of God, as it does not befit so great a sinner to meet his death in such a way. Zaliah now tried in vain to kill Balaam, for through his magic wiles he was proof against every weapon, until Phinehas at last gave Zaliah a sword on both sides of which was engraved a serpent, with the words, "Kill him with that to which he belongs - through this he will die," and with this sword Balaam was killed. 
His corpse was not buried, but his bones rotted, and from then arose several species of harmful snakes, that bring disaster to human beings; and even the worms that devoured his flesh were turned into snakes. The magicians made use of these snakes for three different types of enchantment, for the heads, the bodies, and the tails, had each a different effect. One of the questions that the Queen of Sheba put to Solomon was how to withstand these three different kinds of enchantment, and the wise king knew even this secret, which he then imparted to her.