Lightweight polyimide foams (PIFs) with exceptional thermal resistance and compressive properties were fabricated by heating polyester ammonium salts (PEASs) which were prepared by co‐polymerizing 4, 4’‐diaminobenzanilide (DABA), 4, 4’‐diaminodiphenyl methane (MDA) and 3, 3’, 4, 4’‐benzophenone tetracarboxylic dianhydride (BTDA). Hydrogen bonds were formed between CONH and C = O in the PI chains due to the addition of DABA and the melt viscosity of PEAS precursors increased with increasing content of DABA, which was advantageous to bind the foaming gases for cell expansion. The expansion ratio of PEAS precursors was increased from 633% to 1133% when the molar ratio of MDA/DABA was changed from 10:0 to 6:4. The compressive strength and modulus of PIFM9D1 (i.e., the molar ratio of MDA/DABA was 9:1, foam density: 120.8 kg·m−3) reached as high as 0.59 and 15.0 MPa, respectively. The PIFs possessed prominent thermal performance with the initial thermal degradation temperatures (under both nitrogen and air atmosphere) and glass transition temperatures (as assessed by DSC and DMA) exceeding 511 and 292 °C, respectively. The thermal conductivity of PIFs was lower than 0.049 W·m−1·K−1, which exhibited promising applications for serving as high‐temperature thermal insulation materials in the fields of aerospace, marine, and nuclear sectors among others.This article is protected by copyright. All rights reserved