In 1811, Crawfurd accompanied Raffles on Lord Minto's Java Invasion, which overcame the Dutch. Raffles was appointed Lieutenant-Governor of Java by Minto during the 45-day operation, and Crawfurd was appointed the post of Resident Governor at the Court of Yogyakarta in November 1811. There he took a firm line against Sultan Hamengkubuwana II. The Sultan was encouraged by Pakubuwono IV of Surakarta to assume he had support in resisting the British; who sided with his opponents his son the Crown Prince and Pangeran Natsukusuma. The Sultan's palace, the Kraton Ngayogyakarta Hadiningrat, was besieged and taken by British-led forces in June 1812.