During most parts of the prayer service, a person may face in any direction he desires. However, when he arrives at the climax of the prayer service and gets up in the Amidah to stand before the King of the world, he must turn to face Jerusalem, the place that Hashem chose to endow His Shechinah to the world.
One who stands in prayer outside of Israel must face the Land of Israel, and his heart should be directed towards Jerusalem, the home of the Beit HaMikdash (Temple), and Kodesh HaKodashim (the Holy of Holies). If one stands in Israel, he must face Jerusalem, and his heart should be directed towards Beit HaMikdash and Kodesh HaKodashim. If he stands in Jerusalem, he faces the direction where the Beit HaMikdash stood, and directs his heart to Kodesh HaKodashim (Berachot 30a; Shulchan Aruch 94:1).
Therefore, those reciting the Amidah in the plaza in front of the Kotel must turn and face the direction of the exact place of the Beit HaMikdash. In other words, those standing in the open square must turn slightly to the left, and even those standing in the men’s section in the closed area next to the wall should do the same.
It is customary to position the aron kodesh on the side of the synagogue that faces Jerusalem, so that those standing in prayer also pray towards the direction of the aron kodesh. However, the primary objective is to pray in the direction of Jerusalem. Therefore, if due to error, or because of circumstances beyond our control, the aron kodesh does not exactly face Jerusalem, the people praying should turn to face the direction of Jerusalem (Mishnah Berurah 94:9). Nevertheless, if the entire congregation mistakenly faces the aron kodesh, it is best not to separate oneself from the congregation; instead, one should stand in the same direction that the congregation faces, but turn his head towards Jerusalem (Mishnah Berurah 94:10).
One who does not know the direction of Jerusalem may pray to whichever direction he desires while directing his heart towards his Father in Heaven (Shulchan Aruch 94:3). Even if he subsequently discovers that he was mistaken, it is not necessary to repeat his prayer while facing Jerusalem.[2]