Following the destruction of the Temple, Israel adopted the practice of performing hakafot in the synagogue to commemorate the Temple. Since this was never formally ordained, we find that different customs emerged in the Geonic era, though by the time of the Rishonim, custom crystallized into the relatively uniform custom that is practiced today.
The Torah scroll is placed on the bima, the entire congregation takes their four species in hand, and they circle the bima once each day, and seven times on the seventh day. We circle the Torah because after the destruction of the Temple, Torah study is in lieu of the altar, for one who studies the laws of the offerings is considered as having brought them on the altar. The prevailing custom is that one person stands at the bima and holds the Torah scroll during the hakafot (Ḥida; Pri Megadim), although some Sephardic communities do not insist on this (Kaf Ha-ḥayim 660:6).
Over time, special prayers were composed for recitation during these hakafot. The refrain of these prayers is the phrase “hosha na” (“please save”) and the similar phrase “hoshi’a na,” which is why these prayers are often called “hoshanot.” Depending on custom, these prayers are recited before, during, or after the hakafot.
Someone without a lulav does not circle the bima (Rema 660:2; Birkei Yosef; Kaf Ha-ḥayim 660:13), so it is customary to have such a person stand at the bima and hold the Torah scroll.
The circuits are counterclockwise; that is, if one is facing the bima, he turns to his right to begin his circuit (SA 660:1; MB ad loc. 3).
Some maintain that during hakafot the lulav is held in the same way as it is held to perform the mitzva – with the bundled species in the right hand and the etrog in the left, with the two hands close together (Roke’aḥ; Maharil; Ben Ish Ḥai). Others say that one who needs to hold his siddur in one hand may hold the bundled species and the etrog together in the other (Yafeh La-lev; Ginat Veradim). Both customs are fine.
It is customary to leave the ark open during the hakafot (Kitzur Shulḥan Arukh 137:11).
Some maintain that if there is no Torah scroll, there are no hakafot (Bikurei Yaakov 660:2), while others say hakafot are done even without a Torah scroll (Ben Ish Ḥai, Ha’azinu §15).
The custom of Sephardim and ḥasidim is to perform hakafot after the recitation of Hallel and before the recitation of Kaddish Titkabel (Kaf Ha-ḥayim 660:4). Some Ashkenazim perform hakafot after Musaf (Olat Re’iya, vol. 2, p. 370).
On Shabbat, hakafot are not performed. Some recite the accompanying hoshanot prayers anyway, while others do not (SA 660:3; Kaf Ha-ḥayim ad loc. 23).
Some say that a mourner within the year of the death of a parent does not perform hakafot, since they were instituted to bring joy (Rema 660:2; MB ad loc. 9). Many maintain that a mourner does participate in the hakafot (Beit Yosef; Arizal; Ḥayei Adam 148:19). This is the custom of all Sephardim and many Ashkenazim (Gesher Ha-ḥayim 20:3:60).