One may not recite the Amida prayer too close to his primary rabbi (“rav muvhak”), for if he prays alongside him, and certainly in front of him, he presents himself as his rabbi’s equal at least. On the other hand, he may not pray behind his rabbi, for should the rabbi finish praying before he does, the rabbi will feel uncomfortable because he cannot take three steps backwards – and it would be terrible for one to make his mentor feel uncomfortable. Furthermore, the student may appear as though he is bowing down to his rabbi (SA 90:24; MB 74).
If the student distances himself by four amot (c. two meters), it is permitted. However, if he prays behind his rabbi, he must distance himself four amot and another three paces (c. 60 cm), so that even if he were to prolong his prayer, his rabbi would be able to take three steps backwards.
Who is considered one’s primary rabbi? The one from whom she has learned the majority of her wisdom in one area of the Torah. One of the great Torah leaders of the generation has the same status. Likewise, the rabbi of a place is considered a primary rabbi (AHS YD 242:29; see also Peninei Halakha: Prayer, ch. 3 n. 8). Some say that during the time period that one is learning from a certain rabbi, even if he did not teach her most of her knowledge, at that time, the teacher has the status of her primary rabbi (Divrei Malkiel 2:74).
Concerning a rabbanit (a rabbi’s wife, who is often a teacher and religious guide in her own right), there is a prohibition on praying alongside her in two situations: 1. when she is married to one’s rav muvhak or to one of the prominent Torah leaders of the generation, and her main goal is to assist her husband in his sacred mission; and 2. when she herself is an educator and most of her students’ Torah knowledge or teaching has come from her, in which case, her students must relate to her as they would to a rav muvhak.
Some say that these rulings apply only in a situation where the student chooses to pray next to the rabbanit. But if they were seated near each other in the women’s section, she may pray there, for there is no question of arrogance on the part of the student. In times of need, one may rely on this opinion (Peninei Halakha: Prayer, ch. 3 n. 9). Certainly when the rabbanit invites the student to sit next to her or agrees to the student sitting next to her there is no prohibition or concern of arrogance on the part of the student, and she may pray there.