It's not clear what causes esophageal spasms. However, they appear to be related to atypical functioning of nerves that control the muscles you use when you swallow.
A healthy esophagus usually moves food into your stomach through a series of coordinated muscle contractions. Esophageal spasms make it difficult for the muscles in the walls of your lower esophagus to coordinate in order to move food to your stomach.
There are two types of esophageal spasms — distal esophageal spasm and hypercontractile esophagus, also referred to as jackhammer esophagus.