During the initial Islamic invasion in 639 AD, Egypt was ruled at first by governors acting in the name of the Righteous Caliphs, and then the UmmayadCaliphs in Damascus but, in 747, the Ummayads were overthrown. In 1174, Egypt came under the rule of Ayyubids that lasted until 1252.