Successors to the Majapahit conquerors of Bali established themselves at Gelgel (just south of modern Semarapura) around 1400, with the Gelgel dynasty strengthening the growing Majapahit presence on the island. During the 17th century the successors of the Gelgel line established separate kingdoms and the dominance of the Gelgel court was lost. The court moved to Klungkung in 1710, but never regained a preeminent position.
In 1849 the rulers of Klungkung and Gianyar defeated a Dutch invasion force at Kusamba. Before the Dutch could launch a counterattack, a force from Tabanan arrived and the trader Mads Lange was able to broker a peace settlement.
For the next 50 years, the south Bali kingdoms squabbled, until the raja of Gianyar petitioned the Dutch for support. When the Dutch finally invaded the south, the king of Klungkung had a choice between a suicidal puputan, like the raja of Denpasar, or an ignominious surrender, as Tabanan's raja had done (or cutting a deal like the raja did up the road in Bangli). He chose the first. In April 1908, as the Dutch surrounded his palace, the Dewa Agung and hundreds of his relatives and followers marched out to certain death from Dutch gunfire or the blades of their own kris (traditional daggers). The sacrifice is commemorated in the towering Puputan Monument.