إِذْ يُبَايِعُونَكَ تَحْتَ الشَّجَرَةِ
When they pledged allegiance to you beneath the tree.
«الشجرة» refers to the known tree associated with the specific pledge. The event supplies an identifiable referent without having to introduce it as a completely new, indefinite tree.
Shared situational or historical knowledge can identify a noun even when its exact word has not already appeared. Context is essential to the classification of this use of al-.