The town, named after Wadi Zabid, the wadi (or valley) to its south, is one of the oldest towns in Yemen. Abu Musa Ashaari, one of the Prophet Muhammads companions, came originally from Zabid, and had the Great Mosque of the town built in 628 AD, also still during the Prophet's life. According to tradition, this is the 5th mosque built in the history of Islam. Another sahabi; Amru bin Ma'adi Yakrib also hailed from Zabid and was from the House of Zubaid, an Arabian tribe named after this city. Zabid was the capital of Yemen from the 13th to the 15th century and a centre of the Arab and Muslim world due in large part to its famed University of Zabid and being a centre of Islamic education. It was the capital of the Ziyadid dynasty from 819–1018 and the Najahid dynasty from 1022–1158.