A hiatal hernia occurs when part of the stomach pushes through the opening (hiatus) in the thoracic diaphragm where the esophagus passes on its way to connect to the stomach.