Aseptic loosening and bacterial infection pose significant challenges in the clinical application of titanium (Ti) orthopedic implants, which are primarily caused by insufficient osseointegration and bacterial contamination. To address these issues, a responsive coating on Ti surface is constructed, which achieves enhanced osseointegration and infection elimination by on-demand release of therapeutic gas hydrogen sulfide (H2S) and antibiotic. TiO2 nanotubes (TNT) are anodized on the Ti surface to enhance its bioactivity and serve as reservoirs for the antibiotic. An infection microenvironment-responsive macromolecular H2S donor layer is coated on top of TNT to inhibit premature leakage of antibiotic. This layer exhibits a sustained release of low-dosage H2S, which is capable of promoting the osteogenic differentiation and migration of cells. Moreover, the compactness of the macromolecular H2S donor layer could be broken by bacterial invasion, leading to rapid antibiotic release thus preventing infection. In vitro antibacterial experiments validates significant antibacterial activity of the coating against both Gram-negative (Escherichia coli) and Gram-positive bacteria (Staphylococcus aureus). Crucially, this coating effectively suppresses implant-associated infection with 98.7% antibacterial efficiency in a rat femoral bone defect model, mitigates inflammation at the defect site and promotes osseointegration of the Ti orthopedic implant.