Most common imides are prepared by heating dicarboxylic acids or their anhydrides and ammonia or primary amines. The result is a condensation reaction:
: (RCO)O + R′NH  →  (RCO)NR′ + HO
These reactions proceed via the intermediacy of amides. The intramolecular reaction of a carboxylic acid with an amide is far faster than the intermolecular reaction, which is rarely observed.
They may also be produced via the oxidation of amides, particularly when starting from lactams.
: R(CO)NHCHR  + 2 [O] →  R(CO)N(CO)R  +  HO
Certain imides can also be prepared in the isoimide-to-imide Mumm rearrangement.