His knowledge of the Malay language as well as his wit and ability, gained him favour with Lord Minto, Governor-General of India, and he was sent to Malacca. Then, in 1811, after the invasion and annexation of the Kingdom of Holland by France during Napoleon's war, Raffles had no choice but to leave the country. He mounted a military expedition against the Dutch and French in Java, Indonesia. The war was swiftly conducted by Admiral Robert Stopford, General Frederick Augustus Wetherall
He was appointed assistant secretary to the new Governor of Penang in 1805 and married Olivia Mariamne Fancourt, a widow who was formerly married to Jacob Cassivelaun Fancourt, an assistant surgeon in Madras who had died in 1800. At this time he also made the acquaintance of Thomas Otho Travers, who would accompany him for the next twenty years.