The essential oil (EO) of the herbal pair (HP), Alpinia officinarum‐Cyperus rotundus (HP G‐X) has been conventionally used in traditional Chinese medicine (TCM) for ‘warming the stomach’ and relieving pain. However, its pharmacologically active compounds, as well as the mechanism of its anti‐gastric ulcer properties remain unclear. In this study, the EOs obtained from HP G‐X and its corresponding single herbs were analyzed using GC/MS. A total of 74, 56, and 85 compounds were detected in A. officinarum (GLJ), C. rotundus (XF), and HP G‐X, accounting for 93.2 %, 89.5 %, and 92.0 % of the total content, respectively. GLJ mainly contains 1,8‐cineol (22.0 %) and α‐terpineol (11.8 %), whereas cyperenone (22.4 %) and cyperene (12.3 %) were the major constituents in XF. These four compounds were also detected in the HP G‐X with relatively high composition as 11.8 %, 5.5 %, 11.8 %, and 10.6 %, respectively. Although no new compounds were detected in HP G‐X, the relative concentration of some compounds increased, while others decreased or even disappeared. HP G‐X showed the lowest toxicity (TC50 >800 μg/mL) against human gastric mucosal epithelial cells (GES‐1) and had the best protective effect against ethanol‐induced GES‐1 cell damage compared to the individual herbs. In vitro studies demonstrated that HP G‐X and the corresponding single herbs significantly reduced IL‐6, TNF‐α, and COX‐2. In addition, in vivo investigations indicated that HP G‐X can protect the gastric mucosa of mice from ethanol‐induced damage by inhibiting the inflammatory reaction and providing analgesia. It can also inhibit the expression of NF‐κBp65, COX‐2, and TRPV1 protein, reduce the concentrations of IL‐6 and TNF‐α, and relieve heat‐induced pain. This study further substantiated the traditional application of HP G‐X against gastric ulcers through both in vivo and in vitro investigations.