In September 1939 after Nazi Germany and the Soviet Union both invaded and occupied Poland, as a fulfillment of the Molotov–Ribbentrop Pact they had signed earlier, Lwów initially came under Soviet occupation. Steinhaus considered escaping to Hungary but ultimately decided to remain in Lwów. The Soviets reorganized the university to give it a more Ukrainian character, but they did appoint Stefan Banach (Steinhaus's student) as the dean of the mathematics department and Steinhaus resumed teaching there. The faculty of the department at the school were also strengthened by several Polish refugees from German-occupied Poland. According to Steinhaus, during the experience of this period, he "acquired an insurmountable physical disgust in regard to all sorts of Soviet administrators, politicians and commissars"