The first stones were positioned by Prophet Muhammad and the masjid was completed by his companions, (radiAllahu anhum)
The masjid came to be built, after the prophet stopped over there to pray, on hijrah (migration) from the city of Makkah to Madinah.
It is this masjid that is also called "Masjid al-Taqwa" as mentioned in the Qur’an:
This is masjid-e-quba in Madina Munawarrah. It is first mosque of islam