All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
If it occurred that while a Muslim was on the surface of the moon or any other celestial object, and the time for prayer came, then he should pray just as the people on Earth pray, except that he should turn in the direction of the Earth itself and that is his Qiblah (direction of prayer), as Allaah The Exalted Says (what means): {And wherever you [believers] are, turn your faces toward it [i.e., the Ka‘bah, in prayer].}[Quran 2:144]
"Toward it" means in its direction, and the direction of the Ka‘bah, in relation to the person on the Moon, is in the direction of Earth itself.