The Muslims were great book collectors, and in all the larger towns there was a flourishing book trade. From Baghdad, to Cairo, to Cordoba and to Fez, Muslims built the libraries that housed the world largest book collections of that time.
Quoted from F.B. Artz in his book "The Mind of the MIddle Ages". Third edition revised; The University of Chicago Press, 1980. pages: 152-3:
The Muslims were great book collectors, and in all the larger towns there was a flourishing book trade. The employment of paper rather than papyrus or parchment made books relatively cheap. Besides great libraries attached to the mosques and the larger schools, princes, nobles, and merchants had extensive private collections which they were usually willing to open to qualified scholars.
We hear of a private library in Baghdad, as early as the ninth century, that required a hundred and twenty camels to move it from one place to another. Another scholar of Baghdad refused to accept a position elsewhere because it would take four hundred camels to transport his books; the catalogue of this private library filled ten volumes. This is the more astonishing when it is realized that the library of the king of France in 1300 had only about four hundred titles. In the thirteenth century, before the Tartars sacked the city (1258), Baghdad had thirty-six public libraries and over a hundred book-dealers, some of whom were also publishers employing a corps of copyists. Descriptions of both public and private libraries speak of the classification of books and their arrangement in separate cases or even in separate rooms. Elaborate catalogues were kept, and the larger libraries were staffed with educated librarians, copyists, and binders.
The most extensive public library of which there is a record is a tenth-century foundation in Cairo; it originally contained a hundred thousand volumes. These were later moved into a larger research foundation called the House of Wisdom which, by the eleventh century, claimed to have over a million volumes on its shelves. By 1250 the most valuable material in the Islamic libraries had become available to European scholars in translation. This transference came just in time, for, shortly after the middle of the thirteenth century, the Mongols in the East and the Christians in Spain began to destroy Islamic books in a wholesale manner.
Spain was so stripped of Muslim books that when Philip II, in the sixteenth century, founded the Escorial library, he was unable to find many Arabic books in Spain. Some survived in Morocco, and gradually a collection was built up, though a seventeenth-century catalogue of the Escorial library, then the largest in Spain, showed only 4,000 Islamic titles, lone survivors of one of the worst holocausts of books in history. Fortunately, a large number of Islamic books survived in Egypt, Persia, and India, from whence most of our knowledge of Muslim civilization has come.