Context: Although thyroid function is associated with several risk factors of nonalcoholic fatty liver disease (NAFLD), its role in NAFLD development remains unclear. Objective: We aimed to prospectively investigate the association between variations in thyroid function and NAFLD. Design and Setting: The Rotterdam Study, a large population-based, prospective cohort study. Participants and Main Outcome Measures: Participants with thyroid function measurements at baseline and NAFLD data (ie, at baseline fatty liver index/at follow-up ultrasound) were eligible. Transient elastography was performed to assess the presence of fibrosis in patients with NAFLD, using the liver stiffness measurements more than or equal to 8 kPa as cutoff for clinically relevant fibrosis. The association between thyroid parameters and incident NAFLD was explored by using logistic regression models. Results: A total of 9419 participants (mean age, 64.75 y) were included. The median follow-up time was 10.04 years (interquartile range, 5.70-10.88 y). After adjusting for age, sex, cohort, follow-up time, use of hypolipidemic drugs, and cardiovascular risk factors, higher free T-4 levels were associated with a decreased risk of NAFLD (odds ratio, 0.42; 95% confidence interval [CI], 0.28-0.63). In line, higher TSH levels were associated with an increased risk of having clinically relevant fibrosis in NAFLD (odds ratio, 1.49; CI, 1.04-2.15). Compared with euthyroidism, hypothyroidism was associated with a 1.24-fold higher NAFLD risk (CI, 1.01-1.53). Moreover, NAFLD risk decreased gradually from hypothyroidism to hyperthyroidism (P for trend = .003). Conclusion: Lower thyroid function is associated with an increased NAFLD risk. These findings may lead to new avenues regarding NAFLD prevention and treatment.