Objective: The association between dysregulated thyroid hormone function and cancer risk is inconclusive, especially among different age groups and uncommon malignancies. We sought to determine the relation of TSH and free T4 levels with overall cancer risk as well as risk of specific cancer types. Design and methods: Data on thyroid hormone profile was collected from 375 635 Israeli patients with no prior history of cancer. Cancer cases were identified via the Israel National Cancer Registry. Cox proportional hazards model was used to assess hazard ratios for overall cancer as well as 20 cancer subgroups. Results: In this study, 23 808 cases of cancer were detected over median follow up of 10.9 years. Among patients younger than 50 at inclusion, TSH in the hyperthyroid range, elevated free T4 and subclinical hyperthyroidism were associated with increased cancer risk (HR: 1.3, 1.28 and 1.31, respectively). In contrast, patients 50 or older with clinical hyperthyroidism were at lower cancer risk (HR: 0.64). Elevated TSH was associated with decreased risk of prostate cancer (HR: 0.67). Log-TSH elevation was associated with decreased risk of thyroid cancer (HR: 0.82) and increased risk of melanoma (HR: 1.11) and uterine cancer (HR: 1.27). Elevated free T4 was associated with increased lung cancer risk (HR: 1.54), while free T4 levels above the normal range and clinical hyperthyroidism were related to lower colorectal cancer risk (HR: 0.59 and 0.08, respectively). Conclusions: Thyroid hormones display opposing effects on cancer risk, based on patient age and cancer type.