α-Fe2O3 nanoparticles have been formed on a flexible polyimide (PI) substrate via an ion-exchange and in situ oxidation process in air, which involved doping the ferrous (Fe2+) ions into modified layers of PI films and a subsequent thermal treatment converted Fe2+ into α-Fe2O3 nanoparticles. These nanoparticles would migrate and aggregate compactly onto the surfaces, and thus form continuous layers with semi-conductivity. The phase transition of α-Fe2O3 to Fe3O4 nanolayers occurred when the PI/α-Fe2O3 composite films were heated under a continuous hydrogen/nitrogen gas flow. The effects of the thermal treatment conditions on the oxidation behaviors of Fe2+ and the micro-structures of α-Fe2O3 and Fe3O4 nanolayers were investigated by X-ray diffraction (XRD), scanning electron microscopy (SEM) and transmission electron microscopy (TEM). The phase transition of α-Fe2O3 to Fe3O4 was confirmed by XRD and high-resolution transmission electron microscopy (HRTEM). Vibrating Sample Magnetometer (VSM) measurements showed that the PI/α-Fe2O3 and PI/Fe3O4 composite films presented antiferromagnetism and ferrimagnetism respectively. Both composite films maintained the excellent thermal stability and flexibility of the pure PI films.