Caffeine is one of the most widely consumed substances found in beverages, and has demonstrated anticancer effects in several types of cancer. The present study aimed to examine the anticancer effects of caffeine on gastric cancer (GC) cells (MGC‑803 and SGC‑7901) in vitro, and to determine whether the apoptosis‑related caspase‑9/-3 pathway is associated with these effects. The sustained antiproliferative effects of caffeine on gastric cancer were also investigated. GC cell viability and proliferation were evaluated using cell counting and colony forming assays, following treatment with various concentrations of caffeine. Flow cytometry was performed to assess cell cycle dynamics and apoptosis. Western blot analysis was conducted to detect the activity of the caspase‑9/-3 pathway. The results indicated that caffeine treatment significantly suppressed GC cell growth and viability and induced apoptosis by activating the caspase‑9/-3 pathway. Furthermore, the anticancer effects of caffeine appeared to be sustained, as the caspase‑9/-3 pathway remained active following caffeine withdrawal. In conclusion, caffeine may function as a sustained anticancer agent by activating the caspase‑9/-3 pathway, which indicates that it may be useful as a therapeutic candidate in gastric cancer.