The reaction mechanism involves the formation of a positively charged halonium ion in a molecule that also contains a carboxylic acid (or other functional group that is a precursor to it). The oxygen of the carboxyl acts as a nucleophile, attacking to open the halonium ring and instead form a lactone ring. The reaction is usually performed under mildly basic conditions to increase the nucleophilicity of the carboxyl group.