building Imogiri, his burial place, about fifteen kilometres south of Yogyakarta. Imogiri remains the resting place of most of the royalty of Yogyakarta and Surakarta to this day. Agung died in the spring of 1646, leaving behind an empire that covered most of Java and stretched to its neighbouring islands. Decline Struggles for power Upon taking the throne, Agung's son Susuhunan Amangkurat I tried to bring long-term stability to Mataram's realm, by murdering local leaders that were insufficiently deferential to him, including the still-powerful noble from Surabaya, Pangeran Pekik, his father-in-law, and executed Panembahan Adiningkusuma (posthumous: Panembahan Girilaya), king of Cirebon, his son in-law. He also closed ports and destroyed ships in Javanese coastal cities to prevent them from getting too powerful from their wealth. This action devastated the Javanese coastal economy and crippled the Javanese maritime prowess that had been nurtured since the Singhasari and Majapahit era. This thus turned Mataram into a mainly agricultural inland kingdom for the next centuries. Because of this, Amangkurat I was notarized as a ruthless king. He even massacred 5,000–6,000 ulema and their family members due to their alleged involvement in a coup plot. Despite his political ruthlessness, unlike his father, Amangkurat I was not an accomplished military leader and dare not to pursue confrontation against the Dutch, as in 1646 he signed peace agreement with them. To further his glory, the new king abandoned Karta, Sultan Agung's capital, and moved to a grander red-brick palace in Plered (formerly the palace was built of wood). By the mid-1670s dissatisfaction with the king was turning into open revolt, beginning from the recalcitrant Eastern Java and creeping inward. The Crown Prince (future Amangkurat II) felt that his life was not safe in the court after he took his father's concubine with the help of his maternal grandfather, Pangeran Pekik of Surabaya, making Amangkurat I suspicious of a conspiracy among Surabayan factions to grab power in the capital by using Pekiks’ grandson's powerful position as the Crown Prince. He conspired with Panembahan Rama from Kajoran, west of Magelang, who proposed a stratagem in which the Crown Prince financed Rama's son-in-law, Trunajaya, to begin a rebellion in the East Java. Raden Trunajaya, a prince from Arosbaya, Madura, led a revolt supported by itinerant fighters from faraway Makassar led by Kraeng Galesong. The Trunajaya rebellion moved swiftly and strong, and captured the king's court at Plered in Mataram