During the reign of the ineffectual Ramesses XI, Egypt was becoming chaotic and fragmented. Amenhotep, the high priest in Thebes and the most powerful man in Upper Egypt, was deposed by his people. Pharaoh Ramesses, petitioned by Amenhotep, had no choice but to restore him to office. Ramesses instructed Viceroy Paneshy and his Nubian army to march to Thebes, where after a bloody battle, Amenhotep was restored as high priest. Meanwhile Paneshy made himself the de facto ruler of Lower Egypt. Ramesses sent an army, led by Piankh to roust him, resulting in civil war. Initially Paneshy was successful and succeeded in storming Hardai in Middle Egypt. However, he could not sustain his victories and in 1080 BCE was driven back into the Kush. In what became a military coup, Piankh took over as ruler.