After a clash with the Hittites, the remainded of Ramsses II's long reign was relatively peaceful and prosperous. Nubia was under his control, although there seem to have been difficulties in maintaining the earlier levels of gold production. Ramesses' many new buildings included the temple at Abu Simbel, his mortuary temple at Thebes and momuments at Tanis. He also moved the capital north to Pi-Ramesse. Under his successors, Egypt entered a long period of decline. Merneptah fought and defeated invading Libyans, who were allied to the Sea People. In the reign of the Twentieth Dynasty pharaoh Ramesses III, Egypt was again attacked by Libyans and the Sea People. Three campaigns were fought in the delta before the invaders were beaten.

Although most of Ramesses III's reign was prosperous and the king made many gifts to the temples, toward the end there were problems. One was the first recorded strike in history, which occured when the monthly food rations paid to the royal tomb workers were overdue and the vizier himself had to intervene. More serious was the discovery that several of the king's wives and officials of the harem were involved in a plot to kill him. As punishment, some of the plotters were allowed to kill themselves, while others had their nose and ears cut off.

The next eight rulers were all called Ramesses, and under them Egypt lost what was left of her empire and became increasingly unstable. During these years, the Theban royal tombs were plundered by robbers and the account of their trial survives. When the thefts were discovered, 36 royal mummies were removed from their tombs by officials and hidden in a remote rock shaft, where they were onlyl discovered 3,000 years later. Such thefts were partly the result of reduced policing of the royal necropolis caused by a shortage of funds.

The last ruler of the Twentieth Dynasty was Ramesses XI, and during his reign Egypt was virtually divided between the powerful High Preist of Amun at Thebes and the vizier of Lower Egypt, Smendes, who ruled from Tanis. Although he was still recognized as the pharaoh, the last Ramesses no longer had any authority and withdrew to his residence in the delta. Following his death, Egypt was once again ruled by rival kings from different cities and the country's days of greatness were over. Initially, the descendents of Smendes ruled as kings at Tanis for about 100 years, until 945 BC, and at Thebes there was a line of rulers who were descended from the High Preist. Marriage ties strengthened the alliance between these two dynasties, and this period was reliatively uneventful.

However, as always at times of weak and central authority, new groups of people moved into Egypt. The Libyans, who formerly had been repulsed so frequently, settled in the western delta and the Faiyum. In time, they were Egyptianized and many of their leading families became powerful. Some Libyans were the descendants of captives settled in Egypt by Ramesses III.

One such family, a line of Libyan chiefs, became established in about 945 BC at Bubastis, halfway between Memphis and Tanis. Sheshonq, the head of this family, became the first ruler of the Twenty-Second Dynasty. He renewed Egyptian interest in Nubia, traded with Byblos and invaded Israel in about 925 BC. But the authority of his successors was challenged in Thebes and elsewhere. Within a century, the various Libyan dynasties were at odds with eachother and civil war broke out. As Egypt disintegrated during this confused period, in Nubia a Kushite kingdom, centered on Napata close to the Fourth Cataract, gradually moved its influence northward.