Fast and efficient oil-water separation materials under harsh conditions become urgent requirement for eliminating destruction of environment from offshore oil spill, oily wastewater produced in industry and life. Here, we designed and prepared polyimide (PI) aerogel with strong hydrogen bond by introducing benzimidazole structure. The hydrogen bond increases the intermolecular interactions to overcome the expansion force and capillary force during ice crystal growth and sublimation. The obtained PI aerogel has a mutually interleaved sheet three-dimensional network structure of thin pore walls (about 85 nm), interconnected pores and tortuous channels with a low shrinkage (about 7.8%). Moreover, due to the high hydrophobicity and morphological characteristics, the PI aerogel can be used for oil-water separation continuously under different harsh conditions, such as high viscosity oil (above 570 mPa.s), oil in cold/hot water (0 degrees C/120 degrees C), corrosive solution and emulsion. The separation efficiency and maximum oil flux can reach 99.9% and 14320 L.m(-2) h(-1), respectively. Because of their fast and efficient oil-water separation performance in harsh environments, this PI aerogel shows great potential in the field of petroleum, municipal and industrial wastewater treatment.