Born in Purbalingga, Dutch East Indies, Sudirman moved to Cilacap in 1916 and was raised by his uncle. A diligent student at a Muhammadiyah-run school, he became respected within the community for his devotion to Islam. After dropping out of teacher's college, in 1936 he began working as a teacher, and later headmaster, at a Muhammadiyah-run elementary school. After the Japanese occupied the Indies in 1942, Sudirman continued to teach, before joining the Japanese-sponsored Defenders of the Homeland as a battalion commander in Banyumas in 1944. In this position he put down a rebellion by his fellow soldiers, but was later interned in Bogor. After Indonesia proclaimed its independence on 17 August 1945, Sudirman led a break-out then went to Jakarta to meet President Sukarno. Tasked with overseeing the surrender of Japanese soldiers in Banyumas, he established a division of the People's Safety Body there. On 12 November 1945, at an election to decide the military's commander-in-chief in Yogyakarta, Sudirman was chosen over Oerip Soemohardjo in a close vote. While waiting to be confirmed, Sudirman ordered an assault on British and Dutch forces in Ambarawa. The ensuing battle and British withdrawal strengthened Sudirman's popular support, and he was ultimately confirmed on 18 December.