In 1812, the Johor-Riau Sultanate experienced a succession crisis. The death of the Mahmud Shah III in Lingga left no heir apparent. Royal custom required that the succeeding sultan must be present at his predecessor's deathbed. However at the time Mahmud Shah III died, the eldest prince, Tengku Hussein, was in Pahang to celebrate his marriage to the daughter of the Bendahara (governor). The other candidate was Tengku Hussein's half-brother, Tengku Abdul Rahman. To complicate matters, neither of the candidates was of full royal blood. The mother of Tengku Hussein, Cik Mariam, owed her origin to a Balinese slave lady and a Bugis commoner. Tengku Abdul Rahman had a similarly lowborn mother, Cik Halimah. The only unquestionably royal wife and consort of Mahmud Shah was Engku Puteri Hamidah, whose only child had died an hour after birth. In the following chaos, Engku Puteri was expected to install Tengku Hussein as the next sultan, because he had been preferred by the late Mahmud Shah. Based on the royal "adat" (customary observance), the consent of Engku Puteri was crucial as she was the holder of the "Cogan" (Royal Regalia) of Johor-Riau, and the installation of a new sultan was only valid if it took place with the regalia. The regalia was fundamental to the installation of the sultan; it was a symbol of power, legitimacy and the sovereignty of the state. Nonetheless, Yang Dipertuan Muda Jaafar (then-viceroy of the sultanate) supported the reluctant Tengku Abdul Rahman, adhering to the rules of royal protocol, as he had been present at the late Sultan's deathbed.