Uqba went on: "I have only chosen this place because it is well away from the sea and Roman ships cannot reach it and destroy it. It is well inland." Then he ordered his men to get building, but they complained that the scrub was full of lions and vagabonds and that they were afraid for their lives and refused to do it. So Uqba collected the members of his army who had been Companions of the Prophet [pbuh], twelve of them, and cried out, "O you lions and vermin, we are Companions of the Prophet of God [pbuh], so leave us and if we find any of you here we will kill them!" Then the people witnessed the most extraordinary sight, for the lions carried their cubs and the wolves carried their young and the snakes carried their offspring and they left, one group after another. Many Berbers were converted to Islam as a result of this.
He then established the government house and the houses for the people around it and they lived there for forty years without ever seeing a snake or a scorpion. He laid out the mosque but was uncertain about the direction of the qibla and was very worried. Then he slept, and in the night heard a voice saying, "Tomorrow, go to the mosque and you will hear a voice saying Allahu akbar." Follow the direction of the voice and that will be the qibla God has made pleasing for the Muslims in this land." In the morning he heard the voice and established the qibla and all the other mosques copied it.
Photo credit: Masjid Uqba and cemetery, courtesy of Wikipedia/Douya