"And it pressed Balaam's foot against the wall" (Numbers 22:25). This was the wall of the stones of the heap that Jacob made and set up between himself and Laban, as Jacob said, "Gather stones," as it is stated, "And Jacob said to his brethren, Gather stones" (Genesis 31:46), and he said, "This heap is a witness" (ibid. 31:52). And he transgressed the covenant, for that heap turned against him for ill; therefore he was struck in his foot, and he was lame in one of his feet.
Why the Donkey Crushed Balaam's Foot Against Jacob's Wall of Stones
Midrash Aggadah, Numbers 22:25
ותלחץ את רגל בלעם אל הקיר. הוא היה הקיר של אבני הגל שעשה יעקב והקימו בינו לבין לבן, שאמר יעקב לקטו אבנים, שנאמר ויאמר יעקב לאחיו לקטו אבנים (בראשית לא מו), ואמר עד הגל הזה (שם שם נב), והוא עבר הברית שעבר אותו גל לרעה לו, לכך לקה ברגלו, והוא היה חיגר ברגלו אחת: