a scout. A person may need to look to the right and left in a state of fear, and actions—even if numerous—are excused in such circumstances. The same applies to movements of the eyes. This exception is sound.
Some scholars also made an exception for one praying in the Sacred Mosque, saying that he should look at the Ka‘bah because it is the worshipper’s qiblah. But this view is weak, for looking at the Ka‘bah undoubtedly distracts the worshipper: when he looks at it, he sees the people performing tawaf around it, and they distract him. The correct view is that the Sacred Mosque is like any other mosque: the worshipper should look either at the place of his prostration or straight ahead.
As for looking toward the sky, it is forbidden; indeed, it is among the major sins. The Prophet, peace and blessings be upon him, forbade it and spoke so sternly about it that he said: “Those who raise their eyes toward the sky during the prayer must cease, or else their sight will be snatched away.” (1) In another wording: “Or it will not return to them.” (2) This is a threat, and a threat is only issued concerning something that is among the major sins. Indeed, some scholars held that if a person raises his gaze to the sky while praying, his prayer is invalid. They cited two proofs for this:
The first is that he has turned his face away from the direction of the qiblah, since the Ka‘bah is on the earth, not in the sky.