Sultan Ali spent his last years in Umbai, Malacca, and supported himself with a small monthly stipend which the British East India Company had granted him.[25] He built a palace for himself and lived with his third wife, Cik' Sembuk until his death in June 1877, and was buried in a Mausoleum within the confines of the Umbai mosque.[26][27] Shortly before his death, Sultan Ali willed the Kesang territory to Tengku Mahmood, his 11-year-old son with Cik' Sembuk. His decision was met with considerable disproval among the some Malays in Singapore, who felt that Tengku Alam should be the heir to the Kesang territory as he was the oldest son with Daeng Siti, who was the daughter of a Bugis nobleman, while Cik' Sembuk was a commoner.[28] At the time of Sultan Ali's death, custody of the Kesang territory lay in the hands of Ungku Jalil, Sultan Ali's elder brother. Ungku Jalil handed over the custodianship of the Kesang territory to Maharaja Abu Bakar, after the British government held an election for the Temenggong Paduka Tuan of Muar and the territory's chieftains to decide on the destiny of the Kesang territory, and voted unanimously for Maharaja Abu Bakar as their leader.