After the death of Sultan Salehuddin Shah on 1778, he was succeeded by his son, Raja Ibrahim Marhum Saleh, who then used the title Sultan Ibrahim Shah.[11] In 1784, he was defeated in the attack on Kuala Selangor by the Dutch, forcing him to leave Kota Malawati. He subsequently managed to occupy it back in less than a year with the help of Pahang Sultanate.[12] Sultan Ibrahim Shah allied himself with Perak Sultanate afterwards but the alliance fall apart in a debt dispute.[11]