The arrival of the Muslim Arabs brought significant changes to Gaza; at first some of its churches were transformed into mosques, including the present Great Mosque of Gaza (the oldest in the city), which was later rebuilt by Sultan Baibars, who endowed it with a huge manuscript library containing over 20,000 manuscripts in the 13th century. A large segment of the population swiftly adopted Islam, and Arabic became the official language. In 767 Muhammad ibn Idris ash-Shafi'i was born in Gaza and lived his early childhood there; he founded the Shafi'i religious code, one of the four major Sunni Muslim schools of law ("fiqh"). Security, which was well-maintained during early Muslim rule, was the key to Gaza's prosperity. Although alcohol was banned in Islam, the Jewish and Christian communities were allowed to maintain wine production, and grapes, a major cash crop of the city, were exported mainly to Egypt.