Born in 1675, he was the last in line of a dynasty of the Sultanate of Johor (founded by his grandfather, Sultan Alauddin Ri'ayat Shah II) descended from the Sultans of Melaka (Malacca). As he was still a young boy when his father Sultan Ibrahim died (16 February 1685), Sultan Mahmud II reigned under the joint regency of his mother and the Bendahara Paduka Raja until the death of the latter (27 July 1697).