In 1757, the Dutch defeated the Bugis who controlled Linggi which was a crucial area in terms of tin production and the Dutch reached an agreement with their defeated opponents after defeating the Bugis in 1758. The appearance of British trading ships at Kuala Selangor added to the worries of the Dutch. The British traders first traded opium and cloth, but eventually began to buy tin from Kuala Selangor. British ships frequented Kuala Selangor were the Junk Selangor, captained by James Scott and The Bloome, captained by Francis Light. From 1760 onwards, Kuala Selangor became increasingly active as a tin collection centre. Traders who were unhappy with the price set moved to Selangor when Perak was trading tin with the Dutch. One ‘bahara’ of tin can fetch 38 rial in Kuala Selangor. The current price rose to 39 rial when the Dutch offered 36 rial per ‘bahara’ of tin in Selangor. The discontented Dutch then blamed the Sultan Selangor as being responsible for affecting the tin producers in Linggi, Perak and Rembau to sell tin to Selangor. In 1770s, Sultan Ibrahim (1778-1826) was said to have played two important roles in Selangor’s economy which were maintaining good relations with British to prevent any military threats from the Dutch in Melaka and as the supplier of all tin products from Selangor to the British and offering better prices than the Dutch. Sultan Ibrahim to be aware early on that the Dutch was uncomfortable with him and accused him of influencing the tin-producing regions such as Perak and Rembau to sell tin through Kuala Selangor. In 1786, the economic competition, alongside political problems which surfaced between the Dutch and Johor involving Selangor between 1782 and 1786 finally forced Sultan Ibrahim and the Dutch to sign an agreement. The agreement provided that in order for trading activities in Selangor to continue. Sultan Ibrahim must give in monopoly over the tin trade in Selangor to the Dutch. In 1790, the agreement was renewed and the Dutch later left the Malay Archipelago. The Dutch agreed to temporarily abandon Melaka through the Kew Letters and all its colonies in the East to the British to avoid their annexation by the French following the beginning of the Napoleonic Wars in Europe in 1795. When the wars was ended, the British were to return Melaka to the Dutch. Thus, the British worked to influence the Malay states. In 1824, competition between these two Western powers, the Dutch and the British, led to both signing the English-Dutch Agreement which was the London Agreement and Melaka officially became a British territory.