Interferon-γ is key in limiting Mycobacterium tuberculosis infection. Here we show that vaccination triggered an accelerated interferon-γ response by CD4+ T cells in the lung during subsequent M. tuberculosis infection. Interleukin 23 (IL-23) was essential for the accelerated response, for early cessation of bacterial growth and for establishment of an IL-17-producing CD4+ T cell population in the lung. The recall response of the IL-17-producing CD4+ T cell population occurred concurrently with expression of the chemokines CXCL9, CXCL10 and CXCL11. Depletion of IL-17 during challenge reduced the chemokine expression and accumulation of CD4+ T cells producing interferon-gamma; in the lung. We propose that vaccination induces IL-17-producing CD4+ T cells that populate the lung and, after challenge, trigger the production of chemokines that recruit CD4+ T cells producing interferon-γ, which ultimately restrict bacterial growth.