Potassium phthalimide is a -NH2-synthon which allows the preparation of primary amines by reaction with alkyl halides. After alkylation, the phthalimid is not nucleophile and does not react anymore. Product is cleaved by reaction with base or hydrazine, which leads to a stable cyclic product.
Mechanism of the Gabriel Synthesis
Note: Phthalimide is acidic!