On the way to the emigration from Mecca to Medina, the Prophet Muhammad (peace and blessings of Allaah be upon him) traveled to Kuba, near Madinah. There he stayed for four days. At this time he built the first mosque of Muslims. The mosque that praises the construction of Allah says,
لَمَسۡجِدٌ اُسِّسَ عَلَی التَّقۡوٰی مِنۡ اَوَّلِ یَوۡمٍ اَحَقُّ اَنۡ تَقُوۡمَ فِیۡهِ
The mosque that has been established from the first day, is better suited for your prayers. (Surah Tawbah: 1)
Historians disagree on how Kuba was built in the mosque. In the book ‘Ziadatul Magaji’ of Yunus ibn Bukai, al-Hakam ibn Udba narrates from al-Masudi, when the Prophet (peace and blessings of Allaah be upon him) came to Kuba, said that Amma bin Yasir said, “A place for the Messenger of Allah (peace and blessings of Allaah be upon him).” It must be determined, where he can rest and perform prayers. He then collected some stones and built a mosque. In this way he built the first mosque.
Like some historians, the mosque was built before the emigration of Kuba Nabiji. The Messenger of Allah (PBUH) built the mosque who had previously emigrated. They used to pray there. When the Messenger of Allah (peace and blessings of Allaah be upon him) emigrated to Kuba, he prayed with them there. It was the first mosque where the Prophet (peace be upon him) prayed with his companions publicly with the church.
But according to most historians, the Prophet (peace be upon him) was built in the mosque under his presence and supervision of the migration in Madinah. The Prophet (peace be upon him) himself participated in the construction of Kubar in the mosque. Tabarani Jabir ibn Samura (RA) narrates that if the Prophet (peace be upon him) traveled to Kuba, the Kuba people requested the Prophet (peace be upon him) so that he would build a mosque for them. Then the Messenger of Allah (।) said, “None of you climb this camel’s back.” At first Abu Bakr climbed on the camel’s back, but the camel did not move. He came back and sat down. Then Omar (RA) rose on the camel, but the camel still did not move. He also failed and returned. The Prophet (peace and blessings of Allaah be upon him) said, “Let anyone else get up.” When Ali got up and climbed on the camel’s back, the camel took him. Then the Prophet (peace and blessings of Allaah be upon him) said, “Leave the reins and build a mosque wherever it stops, because it is directed.”
In another narration, Tabarani narrates from Shamus bin Noman (RA) that he said that when the Prophet (peace and blessings of Allaah be upon him) came and laid the foundation of Kuba in the mosque, I saw him stoned in my own hands. His body was shaking because of the weight of the stone. He had dust on his stomach or navel. One Companion said, “O Messenger of Allah, my parents are sacrificed for you, give me the stone.” He said, “No, you would rather pick up another stone.”
Kuba is a specially prestigious mosque in the mosque. There is a special virtue of praying in Kuba in the mosque. Nabiji would occasionally go to the mosque to pray in Kuba. Sahih Bukhari and Sahih Muslims are narrated from Ibn Omar (RA) that the Prophet (peace and blessings of Allaah be upon him) used to visit the Kuba mosque every Saturday, sometimes walking, sometimes riding. Another narration of Sahih Muslims says that the Messenger of Allah (peace and blessings of Allaah be upon him) used to go to the Kuba Mosque, sometimes walking, sometimes walking, and praying two rak’ats there.
It is narrated from Usaid ibn Zuhair Ansari in the Sunnah Tirmizi that the Prophet (peace and blessings of Allaah be upon him) said that praying in the mosque is the equivalent of an Umrah. It is narrated from the Sunnah Nasayat Sahl ibn Hunaif (RA) that Allah’s Messenger (।) said that the person who comes out to the mosque (Kuba mosque) and goes there, receives prayers, he receives an Umrah.