Background: Metformin may show an antibiotic effect, but whether its use can reduce the risk of tuberculosis infection has rarely been investigated in population-based studies. Methods: This is a retrospective cohort analysis of the Taiwan’s National Health Insurance database. New-onset type 2 diabetes patients, 148,468 ever users and 15,799 never users of metformin, identified during 1999–2005 were followed up until 31 December 2011 for the incidence of tuberculosis infection. Hazard ratios were estimated by Cox regression incorporated with the inverse probability of treatment weighting using propensity score. Results: A total of 360 never users and 1976 ever users developed a tuberculosis infection with respective incidence of 510.91 and 282.94 per 100,000 person–years. The overall hazard ratio of presenting a tuberculosis infection among metformin ever users in respect to never users was 0.552 (95% confidence interval: 0.493–0.617). The hazard ratios for the first (<27.10 months), second (27.10–58.27 months), and third (>58.27 months) tertile of cumulative duration of metformin therapy were 1.116 (0.989–1.261), 0.543 (0.478–0.618), and 0.200 (0.171–0.233), respectively; and were 1.037 (0.918–1.173), 0.533 (0.469–0.606), and 0.249 (0.215–0.288), respectively, for the first (<817,000 mg), second (817,000–2,047,180 mg), and third (>2,047,180 mg) tertile of cumulative doses of metformin. The findings were consistent when analyses were restricted to pulmonary tuberculosis. Additionally, regular users of metformin tended to have greater benefit than irregular users. Conclusions: Metformin use is associated with a reduced risk of tuberculosis infection in a dose–response pattern in type 2 diabetes patients.