By 1790, Egypt had been under the rule of the Spanish Empire for nearly half a century, but the occupation had been anything but pacific. The Spanish had hoped that they would now control the trade routes between the Mediterranean and Indian Oceans, but this was to prove to be a much more difficult task than originally anticipated. One major accomplishment however, had been the rebuilding of Alexandria. It had been transformed from a backwater of 4,000 to a major port of 60,000 inhabitants, attracting immigrants from Italy and Greece, and it replaced Cairo the seat of the Spanish Viceroy in 1784. Throughout he rest of the country, the benefits were less widespread. Under Spanish rule, taxes were levied from the merchants and artisans, mostly by Syrian Tax Collectors. Mamluk properties were confiscated, as were those of anyone who rebelled, often being distributed to absentee European landlords. A new land registry was formed, as taxes were levied on rural and urban properties. The new policies caused frequent rebellions, and large scale migration out of Egypt, particularly to Ottoman ruled lands in Anatolia, while others migrated to Nubia, and later Nejd raiding not only Egypt, but Ethiopia as well.
Economically, the collapse of the Eyalet had led to an abolition of the former trade monopolies, destroying many of the local merchants. In their place, new Greek and Armenian merchants, tied to the Spanish trading companies took their place. The local economy was further affected by famines and epidemics. In 1784, a major famine swept Egypt, and this was followed the next year by an epidemic, killing one-fifth of the population. Due to the brutal occupation, coupled with famines and successive epidemics, and migration the population declined from 5 million at the beginning of the century, to barely 1.5 million. Of these, one-third were Christians with 300,000 of them being Copts, many of whom, due to their knowledge of Egyptian Arabic were used by the new administration to watch over the Muslim population. Around 150,000 were Catholics, a mix of Italians, Levantines and Spanish, with the rest being Greek and with a small number of Armenians. The majority of the population however remained Muslim, and had been reduced to a status of second-class citizens, banned from the army and forced to live in separate quarters and wear distinctive clothing. In a reversal of status, they were now only allowed to ride mules, rather than horses. Before Spanish rule, only Muslims could ride horses, and this was just one of the many humiliations heaped upon a vanquished people. However, some would seek revenge, and would be aided by events taking place across the Red Sea in Arabia.
In a small Oasis town of Nejd, a Muslim preacher and scholar named Muhammad ibn Abd-al-Wahhab was born around 1700, he would create a movement aiming to purify Islam, restoring the da'wa or true monotheistic worship. This revivalist movement rejected practises which had become so prevalent in certain sects of Islam, such as praying to saints, making pilgrimages to tombs and special mosques. In 1744, a local ruler, Muhammad ibn Saud made a pact with Wahhab, whereby he would protect and propagate the doctrines of the Wahhabi mission, while ibn Abdul Wahhab would support Saud, giving him glory and power. As a result, the movement grew, and declared jihad against neighbouring tribes, whose practices, he believed to be the work of idolaters. According to his teachings, they were not Muslims, and as a result, fair game for plunder and even murder. Wahhab claimed those who participated in such practises were not just misguided or committing a sin, but were not Islamic. The attraction to the fundamentalist Islamic movement grew, and from Saud's base in Diriyah, Wahhabism spread across Arabia. They would attack the Ottomans, Shia and Bedouins and others as non-believers. The death of Muhammad bin Saud in 1765, led his son and successor, Abdul-Aziz bin Muhammad taking power. Even more zealous than his father, Abdul-Aziz would pursue his campaign of conquest with more fervour. Non-believers were given the option to "convert or die", leading to his small emirate controlling a huge part of Arabia by 1790. Wahhabism had filled the power vacuum left by the Ottomans, and their conquests continued, taking control of Al-Hasa, and threatening Mesopotamia, when they reached the mashes of the Euphrates in 1780. Until then, the Spanish had shown little concern about the Saudis, however, the attacks on Mesopotamia threatened Spain's position as the leading European trading power in the Mesopotamia and Persia.
Fearing the fall of Basra, the centuries old Spanish factory and convent were evacuated to Coveite (Kuwait) in 1793, however, the Pasha of Basra was able to defeat the Saud in 1795. Perhaps more significant was the capture of Medina in 1792, and the following year of Mecca by Saud. The Ottoman attempts to stem the tide of Wahhabism were hampered by the weak control over Arabia, weakened further by the Anglo-Spanish conquest of Egypt and Syria. The Spanish government initially responded by increasing their fortifications on Persian Gulf and sending aid to the Pasha of Baghdad and Basra, even establishing a permanent mission in Baghdad, making Mesopotamia in effect a military protectorate of the Spanish empire. They were however unable to stop the Saudi attack on Karbala in 1801 where thousands of Shia were killed. Additionally, in the Red Sea, Saudi control over Mecca and Medina had spread Wahhabism to Nubia among the Muslim refugees from Egypt. It was also enhanced by those fleeing from English-ruled Syria. The criticism of the Ottoman Caliphate and the call for Jihad appealed to those who wished revenge on the "Franks" (Christians) and the Ottomans.
Beginning in 1793, the Saudi began sending armies to Nubia, taking over Sennar and Darfur, and threatened Ethiopia. With control over Jeddah, attacks on the Egyptian Red Sea ports, most often hit and run plundering became commonplace. As a result, an increasingly large Spanish army was required to defend the territory. In 1796, the Wahhabist forces invaded Egypt from Nubia, reaching Qena and laying waste to much of Southern Egypt. With the situation increasingly dire, the Spanish government responded by sending a 34,000 man army to Egypt in February 1797, among them was Colonel Napoleone di Buonaparte.