Adoptive T cell therapy has demonstrated great promise for treating cancer and other diseases. While extensive effort has been made to improve ex vivo expansion of T cells, strategies for maintaining the proliferation and function of T cells post adoptive transfer are still lacking. Here we report an injectable T cell-responsive macroporous hydrogel that enables in situ activation and expansion of T cells. The macroporous gel is composed of a polymeric network with dispersed macropores (∼150 μm) that are large enough to home T cells. In the presence of T cells that can gradually disrupt the gel network surrounding the macropores, activation cues can be gradually released for in situ activation and expansion of T cells. This T cell-responsive macroporous gel enables expansion of effector T cells in vivo, is stable over weeks upon subcutaneous injection, and results in enhanced CD8+ T cell response and antitumor efficacy. We further show that the T cell-responsive macroporous gel could achieve comparable antitumor efficacy to conventional T cell therapy with a much lower cell dose. This injectable, T cell-responsive macroporous gel provides a platform for in vivo expansion of engineered T cells in a controlled manner, for timely and effective treatment of diseases.