Nowadays, photothermal killing of pathogenic bacteria and treatment of wound infection have attracted great attention owing to effectively avoiding the drawbacks of traditional antibiotics. In this work, an agarose (AG)-based hydrogel containing tannic acid-Fe(III) (TA-Fe) nanoparticles was fabricated by a facile and eco-friendly strategy. The optimal nanocomposite hydrogel showed the good mechanical property and superior processability. More importantly, the nanocomposite hydrogel revealed outstanding photothermal effect, which exhibited a sharp temperature increase of 58 °C during NIR exposure for 10 min. With in vitro antibacterial experiment, the hydrogel could effectively kill of nearly 99 % of bacteria with 10 min of NIR irradiation. Additionally, for the in vivo experiment, the nanocomposite hydrogel could effectively cure wound infection and promote wound healing. Moreover, the hydrogel possessed high biocompatibility. Based on the good mechanical property, outstanding photothermal effect and high biocompatibility, the nanocomposite hydrogel could become a promising antibacterial wound dressings for biomedical applications.