The earliest mosques , opened in 7th century were open-air spaces . They are the Quba Mosque and Masjid al-Nabawi . They have developed significantly from the open-air spaces that were the Quba Mosque and Al-Masjid al-Nabawi in the 7th century .