Abstract Gastric cancer treatment remains a major challenge because of its aggressiveness and spread. In this study, we developed a hydrogel system for the treatment of gastric cancer, which can kill tumor cells through photothermal action and drug treatment. Based on the formation of Schiff base linkage, the OSA/AHA/BP/PTX hydrogel was prepared by mixing oxidized sodium alginate (OSA), aminated hyaluronic acid (AHA), black phosphorus (BP), and paclitaxel (PTX) under physiological conditions, which exhibited excellent photothermal effect and slow release ability PTX. Moreover, CCK-8 and live/dead fluorescent confirmed that OSA/AHA/BP/PTX hydrogel could obvious inhibition the proliferation of gastric cancer cells (SGC7901). More importantly, in vivo experiments further show that the prepared hydrogel can significantly improve the tumor treatment effect of tumor-bearing mice by inducing tumor cell apoptosis and inhibiting the proliferation of new tumor cells. Compared with chemotherapy alone, photothermal combined chemotherapy had a better antitumor effect. The results of this study indicate that the composite hydrogel with controlled release of paclitaxel can be used as a candidate material for cancer treatment.