Fire-resistant and nonsmoking foam can be prepared in desirable density range of 24 to 50 kg/cu m by controlled thermal crosslinking of polybenzimidazole prepolymer. Reproducible foams of specific density can be produced by controlling volative content and melting temperature of prepolymer