General mechanism for nucleophilic substitution:
Though, with an aldehyde or a ketone, the tetrahedral structure is the last product. Along with carboxylic acid derivatives, the lone pair of electrons on oxygen returns to again form the carbonyl π bond (Step 2). As this occurs, the C-Cl bond breaks with both electrons moving onto the chlorine to make a chloride ion that departs the molecule. This describes how the products are created, but why should the C-Cl σ bond break in preference to the C-OMe σ bond or the C-CH3 σ bond? The best description for this involves looking at the leaving groups that would be made from these processes.
Figure: Leaving groups; (a) chloride; (b) methoxide; (c) carbanion.
The leaving groups would be a chloride ion, a methoxide ion and a carbanion, correspondingly. The chloride ion is best leaving group since it is the very much stable. This is since chlorine is much more electronegative as compared to oxygen or carbon and can stabilize the negative charge. This similar mechanism is included in the nucleophilic substitutions of all the another carboxylic acid derivatives and a general mechanism can be drawn.
Figure: General mechanism for nucleophilic substitution.