The Al-Aqsa mosque stands in the footprint of the temple of Jerisalem. The western or “wailing” wall is all that remains of the temple .
CC
That mosque was said to build on the remains of a Byzantine church dedicated to Mary mother of Jesus that was burned by Persians in 614. The Byzantines recovered Jerusalem then a few years later lost it to the Muslims. Then the Muslims out of Damascus were kept from making a pilgrimage to Mecca, which according to Dan Gibson probably was at Petra at the time, so they build on those ruins the mosque that is there today, calling it the farthest mosque even though Muslims hadn’t conquered Jerusalem yet, but who pays attention to details like that?