 After the fall of Malacca to the Portuguese in 1511, Sultan Mahmud withdrew from Teloh Naming to Ulu Muar, then settled in Pagoh and Bentayan.Sultan Mahmud and his descendants built up the Johor Sultanate as the basis of Johor-Riau Empire based in Johore, the Riau Islands, Pahang and all those parts of the old Malacca Sultanate which was not occupied by the Portuguese.Although Malacca had fallen to the Portuguese, Sultan Mahmud and his son Sultan Ahmad had continuously sent his army to attack the Portuguese in Malacca from 1511 till 1526.