Amangkurat II was the Susuhunan of Mataram from 1677 to 1703. Prior to taking the throne, he was the crown prince and had the title Pangeran Adipati Anom.
Amangkurat II became monarch in 1677 at the height of the Trunajaya rebellion. He succeeded his father, Amangkurat I, who died in Tegal after being expelled from Plered, his capital by Raden Trunajaya, a prince from Madura that captured the court in 1677.
Like his father, Amangkurat II was nearly helpless, having fled without an army nor a treasury to build one. In an attempt to regain his kingdom, he made substantial concessions to the Dutch East India Company (VOC), who then went to war to reinstate him. For the Dutch, a stable Mataram empire that was deeply indebted to them would help ensure continued trade on favorable terms. They were willing to lend their military might to keep the kingdom together. The multinational Dutch forces, consisting of light-armed troops from Makasar and Ambon, in addition to heavily equipped European soldiers, first defeated Trunajaya in Kediri in November 1678, and Trunajaya himself was captured in 1679 near Ngantang west of Malang.
Then, in 1681, the alliance of VOC and Amangkurat II forced Pangeran Puger, his younger brother, who styled himself Susuhunan ing Alaga when he seized the throne, to relinquish it. Since the fallen Plered was considered inauspicious, Amangkurat II moved the capital to Kartasura in the land of Pajang (the northern part of the stretch of land between Mount Merapi and Mount Lawu, the southern part being Mataram).
By providing help in regaining his throne, the Dutch brought Amangkurat II under their tight control. Amangkurat II was apparently unhappy with the situation, especially the increasing Dutch control of the coast, but he was helpless in the face of a crippling financial debt and the threat of Dutch military power. The king engaged in a series of intrigues to try to weaken the Dutch position without confronting them head on. For example, he tried to cooperate with other kingdoms such as Cirebon and Johor, and the court sheltered people wanted by the Dutch for attacking colonial offices or disrupting shipping, such as Untung Surapati. In 1685, Batavia sent Captain Tack, the officer who captured Trunajaya, to Amangkurat's court at Kartasura, in order to capture Surapati and negotiate further details into the agreement between VOC and Amangkurat II. Tack was killed when pursuing Surapati in Kartasura, but Batavia decided to do nothing since the situation in Batavia itself was far from stable, such as the insurrection of Captain Jonker, native commander of Ambonese settlement in Batavia, in 1689. Mainly due to this incident, by the end of his reign, Amangkurat II was deeply distrusted by the Dutch, but Batavia were similarly uninterested in provoking another costly war on Java.
Amangkurat II died in 1703 and was briefly succeeded by his son, Amangkurat III (r. 1703-8).