Ahmad Shah succeeded Mahmud when Mahmud mistakenly killed the Bendahara Tun Mutahir and the Bendahara's family after Raja Mudaliar accused Mutahir of planning a rebellion. Ahmad Shah was deemed incompetent and was killed by Mahmud Shah himself in 1513 after a failed attempt to retake Malacca from the Portuguese. Mahmud Shah then reclaimed the throne, although by then the Malacca sultanate had been abolished, thus making him a pretender.