The Portuguese were ousted by the Dutch East India Company, who during the conflicts between the Kozhikode and the Kochi, gained control of the trade. They lost to Dutch at Quilon after 1661 and later, the Portuguese left south-western coast. The Dutch in turn were weakened by constant battles with Marthanda Varma of the Travancore Royal Family, and were defeated at the Battle of Colachel in 1741. An agreement, known as "Treaty of Mavelikkara", was signed by the Dutch and Travancore in 1753, according to which the Dutch were compelled to detach from all political involvement in the region. In the 18th Century, Travancore King Sree Anizham Thirunal Marthanda Varma annexed all the kingdoms up to Cochin through military conquests, resulting in the rise of Travancore to pre-eminence in Kerala. The Kochi ruler sued for peace with Anizham Thirunal and Malabar came under direct British rule until India became independent.