The Mataramish king, Amangkurat I, escaped to the north coast with his eldest son, the future king Amangkurat II, leaving his younger son Pangeran Puger in Mataram. Apparently more interested in profit and revenge than in running a struggling empire, the rebel Trunajaya looted the court and withdrew to his stronghold in Kediri, East Java, leaving Prince Puger in control of a weak court.