Throughout Egypt's history, different cities have risen and fallen as the seat of political, cultural, and commercial power. These cities are usually built on the Nile, which gave the rulers control over the movement of ships and goods along the river. After uniting Egypt around 3200 BC, King Menes established Enb-Hej, or the White Wall, now known as Memphis. Located near the tip of the Delta, it became a great religious and administrative center during most of the Old Kingdom. Ptah was the patron god of Memphis. The nearby necropolis at Saqqara was a favourite burial ground for pharaohs. Memphis remained prosperous through the Roman times but declined until the Arab conquest, when Muslims took stone from its ruins to build Cairo.
After a period of political disorder, Montuhotep the First reunited Egypt during the Eleventh Dynasty and moved the political capital south to Thebes, currently known as Luxor. The patron god of Thebes was Amun, "the Hidden One," who formed the Theban triad with Mut and Khonsu. Rulers were buried in the great mortuary complexes in the Valley of the Kings. Thebes declined after being attacked by the Assyrians and Romans.
Egypt was conquered by Alexander the Great in 332 BC. Under the Ptolemies, the capital was transferred to Alexandria shortly afterwards. Alexandria lies at the western extremity of the Nile Delta on the sandy strip of land that separates Lake Mareotis from the Mediterranean Sea. Under the Greeks, Alexandria became the cultural and economic capital of the ancient world. It was famous for the great library and the Museion, or museum. The Serapeum, where the patron god Serapis was worshiped, was also located there. As one of the Mediterranean's busiest ports, it was home to the great lighthouse, the Pharos of Alexandria. The city remained an important port and shipbuilding center through the Muslim era.
After the fragmentation of the Roman empire, and after being ruled by the Byzantine empire, Egypt was conquered by Amr Ibn al-As. Amr Ibn al-As established a new capital, Al-Fustat, at the eastern side of the river near the old Roman fortress of Babylon. Because of its location on the Nile between Upper and Lower Egypt, it became a port for the trade from China, India, Yemen, and Europe and the meeting point for Muslims from West Asia and North Africa. Shipbuilding was established as an important industry by Mohammad Ibn Tughj Al-Ikhshid in AH 324 (AD 936) until the reign of Al-Nasir Mohammad Ibn Qala'un. Ahmed Ibn Tulun in AD 868 established El-Quatae as the new capital, where it remained until AD 969 when the Fatimids took over and founded Al-Qahira, which was an enclosed royal city. Salah al-Din expelled the Fatimids and allowed the public to build in and around the royal city, which became Cairo. He built the Citadel in AD 1176 - 1177 on Cairo's most easily defended hill and expanded the walls to enclose the growing city. Building projects for madrassas, or colleges, and mosques made Cairo a great center for Muslim scholarship.