Primary amides can be converted to nitriles by strong dehydrating agents such as SOCl2, P2O5, and POCl3:

Before going into the mechanisms of these reactions. Let’s first address one important question you might be wondering about?
Why is this a dehydration?
It is true that the structural changes do not look like the dehydrations we used to see in the elimination reactions of alcohols. However, conceptually it is the same process of “removing water” from the staring material. The two hydrogens of the amine and the carbonyl oxygen make up an H2O:
Amide Dehydration Mechanism by SOCl2
The reaction starts with a nucleophilic attack of the C=O oxygen which converts into a good leaving and then eliminated in the following steps:

The last step is irreversible formed by loss of good leaving groups and entropy factors.
Amide Dehydration Mechanism by POCl3
The dehydration of mechanism of amides by POCl3 is very similar to the one with SOCl2. The C=O oxygen is converted into a good leaving group and eliminated in a later step:

Amide Dehydration Mechanism by P2O5
P2O5 is another powerful dehydration agent which converts amides to nitriles by a similar mechanism:

Need some good practice on the reactions of carboxylic acids and their derivatives?
Check this 45-question, Multiple-Choice Quiz with a 50-min Video Solution covering the reactions of acids, esters, lactones, amides, acid chlorides and etc.
Carboxylic Acids and Their Derivatives Quiz
Check Also
- Preparation of Carboxylic Acids
- Naming Carboxylic Acids
- Naming Nitriles
- Naming Esters
- Naming Carboxylic Acid Derivatives – Practice Problems
- Fischer Esterification
- Ester Hydrolysis by Acid and Base-Catalyzed Hydrolysis
- What is Transesterification?
- Esters Reaction with Amines – The Aminolysis Mechanism
- Ester Reactions Summary and Practice Problems
- Preparation of Acyl (Acid) Chlorides (ROCl)
- Reactions of Acid Chlorides (ROCl) with Nucleophiles
- R2CuLi Organocuprates – Gilman Reagent
- Reaction of Acyl Chlorides with Grignard and Gilman (Organocuprate) Reagents
- Reduction of Acyl Chlorides by LiAlH4, NaBH4, and LiAl(OtBu)3H
- Preparation and Reaction Mechanism of Carboxylic Anhydrides
- Amides – Structure and Reactivity
- Naming Amides
- Amides Hydrolysis: Acid and Base-Catalyzed Mechanism
- Amide Reduction Mechanism by LiAlH4
- Reduction of Amides to Amines and Aldehydes
- Amides Preparation and Reactions Summary
- Amides from Carboxylic Acids-DCC and EDC Coupling
- The Mechanism of Nitrile Hydrolysis To Carboxylic Acid
- Nitrile Reduction Mechanism with LiAlH4 and DIBAL to Amine or Aldehyde
- The Mechanism of Grignard and Organolithium Reactions with Nitriles
- The Reactions of Nitriles
- Converting Nitriles to Amides
- Carboxylic Acids to Ketones
- Esters to Ketones
- Carboxylic Acids and Their Derivatives Practice Problems
- Carboxylic Acids and Their Derivatives Quiz
- Reactions Map of Carboxylic Acid Derivatives
Soooooooo much helpful for my jee advanced preparation thanks a lot!
Glad to hear that, Vijayraj.
Amazing explanation
Very less people explain all the three mechanism
Amazing teacher
Hope you Excel in whatever you aim
Thank you, Tejas.
What about imidoyl chloride formation where instead of the chloride acting as a base, it attacks the carbon of the imine intermediate?
Superrr doc