Heath tells us that "the Caliph al-Mansur (754-775) sent a mission to the Byzantine Emperor as the result of which he obtained from him a copy of Euclid among other Greek books, and again that the Caliph al-Ma'mun (813-833) obtained manuscripts of Euclid, among others, from the Byzantines."
Most of the Greek learning that was preserved in the Library at Alexandria must have ended up in Rome before the Christians and Arabs gradually destroyed it. It is reasonable to think that copies of pagan books then made their way from Rome, the capital of the old, western Roman Empire, to Constantinople, the capital of the new, eastern Roman Empire, before Rome was sacked in the 5th Century. Constantinople did not fall until 1203, leaving plenty of time for Greek science to migrate into the Islamic empire.
The first Arabic translation that we know of was made by Al-Hajjaj j. b. Yusuf b. Matar (Al-Hajjaj) in the 8th Century. A manuscript copy of this version still exists. It is one of many manuscripts of Arabic translations that have survived.
The translation of Greek works into Arabic peaked under Al-Ma'mun (813-833) who "founded a research institute, the 'House of Wisdom,' in Baghdad," headed by Hunayn ibn Ishaq (808-873) in collaboration with his son, Ishaq ibn Hunayn, two of the most important translators of Greek works. (Lindberg, 169)
In 747 the Arab empire extended into Spain, establishing schools and libraries. Muslim Spain, according to Lindberg, became the focus of translation of the Arabic translations of Greek science into Latin:
"Spain had the advantage of a brilliant Arabic culture, an ample supply of Arabic books, and communities of Christians (known as Mozarabs) who had been allowed to practice their religion under Muslim rule and who could now help to mediate between the two cultures." (Lindberg, 204)
In the 10th c., Arab libraries at Baghdad and Cordova, Spain, were the first to rival the Library at Alexandria. (Sarton, 12) When Spain fell to Christian armies in the 11th c., the riches of its libraries were preserved. (Lindberg, 204)
Heath (p. 367) agrees with Lindberg's assessment of the importance of the Spanish connection, adding that it was Athelhard's translation from Arabic to Latin of a Spanish copy of Euclid that kindled European interest in Greek mathematics.