Before the emergence of Selangor as a political entity, ancient settlements existed along all the major rivers between Bernam and Lukut rivers, with two important settlements Klang and Jeram, were governed by princes and chieftains appointed by Melaka and later Johor. At the end of the 17th century, Buginese emigrants began establishing settlements in Selangor. A power struggle in Johor in the early 18th century opened the door for Buginese ascendancy, securing their position by creating the position of Yamtuan Muda in Johor. As their influence expanded, the Selangor region became their stronghold, governed by a succession of Buginese chiefs.
The death of the second Yamtuan Muda, Opu Daeng Chelak in 1745, brought about the power struggle within their own ranks. As his son, Raja Lumu was deemed too young to succeed, the title was passed to his cousin Daeng Kemboja. Raja Lumu was instead given control of Selangor with the assistance of a Suliwatang ('Regent'). By the time Raja Lumu came of age, he began seeking to consolidate his position against his cousin, by breaking away Selangor from the Johor empire. In November 1766, he was installed by Perak's Sultan Mahmud II, as the independent Ruler of Selangor with the title Sultan. The following is the family tree of Selangor, from the establishment of the sultanate in until present day.