The sultanate has its origin as a vassal to Melaka, with its first Sultan was a Melakan prince, Muhammad Shah, himself the grandson of Dewa Sura, the last pre-Melakan ruler of Pahang. Over the years, Pahang grew independent from Melakan control and at one point even established itself as a rival state to Melaka until the latter's demise in 1511. During this period, Pahang was heavily involved in attempts to rid the Peninsula of the various foreign imperial powers; Portugal, Holland and Aceh. After a period of Acehnese raids in the early 17th century, Pahang entered into the amalgamation with the successor of Melaka, Johor, when its 14th Sultan, Abdul Jalil Shah III, was also crowned the 7th Sultan of Johor. After a period of union with Johor, it was eventually revived as a modern sovereign Sultanate in the late 19th century by the Bendahara dynasty.