Meanwhile, with disruption to the economy and trade in the British Straits Settlements, and concerns over security especially occurrences of piracy, the British became increasingly involved in the affairs of Selangor. In July 1871, due to an attack by pirates that was traced to Raja Mahadi's stronghold Kuala Selangor, the British attacked and captured Kuala Selangor, drove Mahadi's men out and handed the town to Tengku Kudin. Kudin however refused to yield control of revenue from the town to Raja Musa who had previously ruled Kuala Selangor, which prompted Raja Musa to join Mahadi's side. The Sultan of Selangor, who had bestowed Langat upon Tengku Kudin to help him fund his war, also began to be concerned about the rising power of Tengku Kudin.