 However, in 1861, James Brooke went to Brunei, in hopes of forcing the Sultan of Brunei to banish Syarif Masahor to Selangor once and for all.Masahor eventually arrived at Klang, where he became an adviser to Sultan Abdul Samad.During the Klang War however, Syarif Masahor sided with the rebellious Klang territorial chief Raja Mahadi who did not recognise Sultan Abdul Samad's rule.