In 1839 a war broke out between the two kingdoms, which resulted in the defeat of Singasari, but the Mataram king was killed in action, he left 2 sons, crown prince Gde Ngurah Karangasem and Anak Agung Ketut Ngurah Karangasem.