The First Javanese War of Succession was a struggle between Sultan Amangkurat III of Mataram and the Dutch East India Company who supported the claim of the Sultan's uncle, Pangeran Puger to the throne.
Amangkurat II died in 1703 and was briefly succeeded by his son, Amangkurat III. The Dutch believed they had found a more reliable client in his uncle Pangeran Puger. Tensions increased when Amangkurat was accused of giving refuge to the rebel Surapati.[4] Pangeran Puger accused Amangkurat before the Dutch of planning an uprising in East Java. Unlike Pangeran Puger, Amangkurat III inherited blood connection with Surabayan ruler, Jangrana II, from Amangkurat II and this lent credibility to the allegation that he cooperated with the now powerful Untung Surapati in Pasuruan. Panembahan Cakraningrat II of Madura, VOC’s most trusted ally, persuaded the Dutch to support Pangeran Puger. Pangeran Puger took the title of Pakubuwana I upon his accession in June 1704.
Together with the Dutch, Pakubuwono defeated Amangkurat who fled east and received refuge from Surapati who had set up his own kingdom. The war dragged on for five years before the Dutch managed to install Pakubuwana. In August 1705, Pakubuwono I’s retainers and VOC forces captured Kartasura without resistance from Amangkurat III, whose forces cowardly turned back when the enemy reached Ungaran. Surapati’s forces in Bangil, near Pasuruan, was crushed by the alliance of VOC, Kartasura and Madura in 1706.
Jangrana II, who tended to side with Amangkurat III and did not venture any assistance to the capture of Bangil, was called to present himself before Pakubuwana I and murdered there by VOC’s request in the same year. Amangkurat III ran away to Malang with Surapati’s descendants and his remnant forces but Malang was then a no-man’s-land who offered no glory fit for a king. Therefore, though allied operations to the eastern interior of Java in 1706–08 did not gain much success in military terms, the fallen king surrendered in 1708 after being lured with the promises of household (lungguh) and land, but he was banished to Ceylon along with his wives and children.